]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Fix check for initial '-' in argv_to_abspath.
authorDaira Hopwood <daira@jacaranda.org>
Mon, 19 Oct 2015 17:24:33 +0000 (18:24 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Mon, 28 Dec 2015 15:30:05 +0000 (15:30 +0000)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/util/encodingutil.py

index 14751205dd42c9129d521755aea6e011a55bec34..f97c4822c1a7b072f3181f9f3019efd288864333 100644 (file)
@@ -95,15 +95,17 @@ def argv_to_unicode(s):
     except UnicodeDecodeError:
         raise usage.UsageError("Argument %s cannot be decoded as %s." %
                                (quote_output(s), io_encoding))
-    if local_dir.startswith('-'):
-        raise usage.UsageError("Argument %s cannot start with a -." % (quote_output(s),))
 
 def argv_to_abspath(s):
     """
     Convenience function to decode an argv element to an absolute path, with ~ expanded.
     If this fails, raise a UsageError.
     """
-    return abspath_expanduser_unicode(argv_to_unicode(s))
+    decoded = argv_to_unicode(s)
+    if decoded.startswith(u'-'):
+        raise usage.UsageError("Path argument %s cannot start with '-'.\nUse %s if you intended to refer to a file."
+                               % (quote_output(s), quote_output(os.path.join('.', s))))
+    return abspath_expanduser_unicode(decoded)
 
 def unicode_to_argv(s, mangle=False):
     """