forked from TrueCloudLab/rclone
fs/config: don't print errors about --config if supplied - fixes #2397
Before this change if the rclone was running in an environment which couldn't find the HOME directory, it would print a warning about supplying a --config flag even if the user had done so.
This commit is contained in:
parent
99201f8ba4
commit
dbb4b2c900
1 changed files with 17 additions and 4 deletions
|
@ -152,11 +152,24 @@ func makeConfigPath() string {
|
||||||
return homeconf
|
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)
|
// Default to ./.rclone.conf (current working directory)
|
||||||
fs.Errorf(nil, "Couldn't find home directory or read HOME or XDG_CONFIG_HOME environment variables.")
|
if !configSupplied {
|
||||||
fs.Errorf(nil, "Defaulting to storing config in current directory.")
|
fs.Errorf(nil, "Couldn't find home directory or read HOME or XDG_CONFIG_HOME environment variables.")
|
||||||
fs.Errorf(nil, "Use --config flag to workaround.")
|
fs.Errorf(nil, "Defaulting to storing config in current directory.")
|
||||||
fs.Errorf(nil, "Error was: %v", err)
|
fs.Errorf(nil, "Use --config flag to workaround.")
|
||||||
|
fs.Errorf(nil, "Error was: %v", err)
|
||||||
|
}
|
||||||
return hiddenConfigFileName
|
return hiddenConfigFileName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue