Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

fs/config: don't print errors about --config if supplied - fixes #2397

Nick Craig-Wooddbb4b2c900de
diff --git a/fs/config/config.go b/fs/config/config.go
index b3fa43972..ad4d2ea3d 100644
--- a/fs/config/config.go
+++ b/fs/config/config.go
@@ -152,11 +152,24 @@ func makeConfigPath() string {
return homeconf
}
+ // Check to see if user supplied a --config variable or environment
+ // variable. We can't use pflag for this because it isn't initialised
+ // yet so we search the command line manually.
+ _, configSupplied := os.LookupEnv("RCLONE_CONFIG")
+ for _, item := range os.Args {
+ if item == "--config" || strings.HasPrefix(item, "--config=") {
+ configSupplied = true
+ break
+ }
+ }
+
// Default to ./.rclone.conf (current working directory)
- fs.Errorf(nil, "Couldn't find home directory or read HOME or XDG_CONFIG_HOME environment variables.")
- fs.Errorf(nil, "Defaulting to storing config in current directory.")
- fs.Errorf(nil, "Use --config flag to workaround.")
- fs.Errorf(nil, "Error was: %v", err)
+ if !configSupplied {
+ fs.Errorf(nil, "Couldn't find home directory or read HOME or XDG_CONFIG_HOME environment variables.")
+ fs.Errorf(nil, "Defaulting to storing config in current directory.")
+ fs.Errorf(nil, "Use --config flag to workaround.")
+ fs.Errorf(nil, "Error was: %v", err)
+ }
return hiddenConfigFileName
}