Browse code

Merge pull request #311 from alertedsnake/bugfix_default_cfgfile_path

Bugfix: don't rely on $HOME to be set

Matt Domsch authored on 2014/04/11 12:32:01
Showing 1 changed files
... ...
@@ -2010,10 +2010,11 @@ def main():
2010 2010
     config_file = None
2011 2011
     if os.getenv("S3CMD_CONFIG"):
2012 2012
         config_file = os.getenv("S3CMD_CONFIG")
2013
-    elif os.getenv("HOME"):
2014
-        config_file = os.path.join(os.getenv("HOME"), ".s3cfg")
2015 2013
     elif os.name == "nt" and os.getenv("USERPROFILE"):
2016 2014
         config_file = os.path.join(os.getenv("USERPROFILE").decode('mbcs'), "Application Data", "s3cmd.ini")
2015
+    else:
2016
+        from os.path import expanduser
2017
+        config_file = os.path.join(expanduser("~"), ".s3cfg")
2017 2018
 
2018 2019
     preferred_encoding = locale.getpreferredencoding() or "UTF-8"
2019 2020