]> arthur.barton.de Git - bup.git/commitdiff
Default to stdin/stdout in bup meta when -f is not specified.
authorRob Browning <rlb@defaultvalue.org>
Mon, 26 Dec 2011 19:51:45 +0000 (13:51 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sat, 20 Oct 2012 00:56:38 +0000 (19:56 -0500)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
Documentation/bup-meta.md
cmd/meta-cmd.py

index 853d0977de67219c5a88bab7ceb9f87a464dbcab..a53cc4cdaa365d8b5163681606188c083e59dd7e 100644 (file)
@@ -37,7 +37,7 @@ access permissions, etc.) for a set of filesystem paths.
 
 -t, \--list
 :   Display information about the metadata in an archive.  Read the
-    archive from standard output unless `--file` is specified.
+    archive from standard input unless `--file` is specified.
 
 -x, \--extract
 :   Extract a metadata archive.  Conceptually, perform `--start-extract`
index 4d4aac6073f296531f0dfd486286931a7710bc1d..b557ba3a661364747188d019861036fdeb336a67 100755 (executable)
@@ -15,10 +15,15 @@ from bup.helpers import handle_ctrl_c, log, saved_errors
 
 
 def open_input(name):
-    if name != '-':
-        return open(name, 'r')
-    else:
+    if not name or name == '-':
         return sys.stdin
+    return open(name, 'r')
+
+
+def open_output(name):
+    if not name or name == '-':
+        return sys.stdout
+    return open(name, 'w')
 
 
 optspec = """
@@ -61,10 +66,7 @@ if action_count == 0:
 if opt.create:
     if len(remainder) < 1:
         o.fatal("no paths specified for create")
-    if opt.file != '-':
-        output_file = open(opt.file, 'w')
-    else:
-        output_file = sys.stdout
+    output_file = open_output(opt.file)
     metadata.save_tree(output_file,
                        remainder,
                        recurse=opt.recurse,