diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index c4589307a082e..8cf86773fb43f 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ +#include #include #include #include @@ -174,7 +175,7 @@ void help() std::cout << " --user, -u [name] Use [name] as the login name" << std::endl; std::cout << " --password, -p [pass] Use [pass] as password" << std::endl; std::cout << " -n Use netrc (5) for login" << std::endl; - std::cout << " --non-interactive Do not block execution with interaction" << std::endl; + std::cout << " --non-interactive Do not block execution with interaction and tries to read $NC_USER and $NC_PASSWORD if not set by other means" << std::endl; std::cout << " --max-sync-retries [n] Retries maximum n times (default to 3)" << std::endl; std::cout << " --uplimit [n] Limit the upload speed of files to n KB/s" << std::endl; std::cout << " --downlimit [n] Limit the download speed of files to n KB/s" << std::endl; @@ -351,6 +352,7 @@ int main(int argc, char **argv) // 2. From options // 3. From netrc (if enabled) // 4. From prompt (if interactive) + // 5. From environment (if non-interactive) QString user = hostUrl.userName(); QString password = hostUrl.password(); @@ -382,7 +384,15 @@ int main(int argc, char **argv) if (password.isEmpty()) { password = queryPassword(user); } + } else { + if (user.isEmpty()) { + user = QString::fromUtf8(qgetenv("NC_USER")); + } + if (password.isEmpty()) { + password = QString::fromUtf8(qgetenv("NC_PASSWORD")); + } } + // Find the folder and the original owncloud url