From: Rob Browning Date: Mon, 26 Dec 2011 19:51:45 +0000 (-0600) Subject: Default to stdin/stdout in bup meta when -f is not specified. X-Git-Tag: bup-0.25-rc2~119 X-Git-Url: https://arthur.barton.de/gitweb/?a=commitdiff_plain;h=27216754ca382bc2c4fe36d95d9cfc305a38a0ba;p=bup.git Default to stdin/stdout in bup meta when -f is not specified. Signed-off-by: Rob Browning Reviewed-by: Zoran Zaric --- diff --git a/Documentation/bup-meta.md b/Documentation/bup-meta.md index 853d097..a53cc4c 100644 --- a/Documentation/bup-meta.md +++ b/Documentation/bup-meta.md @@ -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` diff --git a/cmd/meta-cmd.py b/cmd/meta-cmd.py index 4d4aac6..b557ba3 100755 --- a/cmd/meta-cmd.py +++ b/cmd/meta-cmd.py @@ -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,