Hi -- Thanks for s3cmd!  Just found a minor need to make use of an
environment variable for setting a config file.  It makes using s3cmd
repeatedly much more convenient for those who need to use it with
multiple accounts, so you don't have to keep saying:

  s3cmd --config=~/s3cmd-config1 ...
  s3cmd --config=~/s3cmd-config1 ...

Now I can just set:

  export S3CMD_CONFIG=~/s3cmd-config1
  s3cmd ...
  s3cmd ...

Patch:

Index: s3cmd
===================================================================
--- s3cmd       (revision 395)
+++ s3cmd       (working copy)
@@ -1466,8 +1466,15 @@
        #optparser.disable_interspersed_args()

        config_file = None
-       if os.getenv("HOME"):
+       # Let user override config file with environment variable.
+       # This avoids having to use `--config=` repeatedly in a script.
+       config_envar = "S3CMD_CONFIG"
+       if os.getenv(config_envar):
+               config_file = os.getenv(config_envar)
+    # Non-Windows.
+       elif os.getenv("HOME"):
                config_file = os.path.join(os.getenv("HOME"), ".s3cfg")
+    # Windows.
        elif os.name == "nt" and os.getenv("USERPROFILE"):
                config_file = os.path.join(os.getenv("USERPROFILE"), 
"Application
Data", "s3cmd.ini")


Also, attached in case the formatting gets munged.

Also, you might want to add an ENVIRONMENT VARIABLES section to the
manpage.  I couldn't immediately tell if you're auto-generating
s3cmd.1 so I didn't add the tidbit.

-- 
@MicahElliott | m...@micahelliott.com | http://MicahElliott.com
@uGraph | mi...@ugraph.com | http://uGraph.com
Index: s3cmd
===================================================================
--- s3cmd	(revision 395)
+++ s3cmd	(working copy)
@@ -1466,8 +1466,15 @@
 	#optparser.disable_interspersed_args()
 
 	config_file = None
-	if os.getenv("HOME"):
+	# Let user override config file with environment variable.
+	# This avoids having to use `--config=` repeatedly in a script.
+	config_envar = "S3CMD_CONFIG"
+	if os.getenv(config_envar):
+		config_file = os.getenv(config_envar)
+    # Non-Windows.
+	elif os.getenv("HOME"):
 		config_file = os.path.join(os.getenv("HOME"), ".s3cfg")
+    # Windows.
 	elif os.name == "nt" and os.getenv("USERPROFILE"):
 		config_file = os.path.join(os.getenv("USERPROFILE"), "Application Data", "s3cmd.ini")
 
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
S3tools-general mailing list
S3tools-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/s3tools-general

Reply via email to