From 15708b8821d6201be4f5e3782bb0a12a8f52875f Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Wed, 31 Dec 2014 18:06:28 +0100 Subject: [PATCH] Fix formatting of usage message (especially newlines) Bug introduced by commit 82816c9, "Don't include newline (NL) character in exception messages". Oops. Signed-off-by: Alexander Barton --- lib/bup/options.py | 4 ++-- main.py | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/bup/options.py b/lib/bup/options.py index a15220a..65702e2 100644 --- a/lib/bup/options.py +++ b/lib/bup/options.py @@ -228,14 +228,14 @@ class Options: """Print usage string to stderr and abort.""" sys.stderr.write(self._usagestr) if msg: - sys.stderr.write(msg) + sys.stderr.write("\n" + msg) e = self._onabort and self._onabort(msg) or None if e: raise e def fatal(self, msg): """Print an error message to stderr and abort with usage string.""" - msg = '\nerror: %s\n' % msg + msg = 'Error: %s!' % msg return self.usage(msg) def parse(self, args): diff --git a/main.py b/main.py index 45a0e8a..0a63de2 100755 --- a/main.py +++ b/main.py @@ -31,7 +31,8 @@ os.environ['WIDTH'] = str(tty_width()) def usage(msg=""): log('Usage: bup [-?|--help] [-d BUP_DIR] [--debug] [--profile] ' - ' [options...]\n\n') + ' [options...]') + log('') common = dict( ftp = 'Browse backup sets using an ftp-like client', fsck = 'Check backup sets for damage and add redundancy information', @@ -45,12 +46,12 @@ def usage(msg=""): web = 'Launch a web server to examine backup sets', ) - log('Common commands:\n') + log('Common commands:') for cmd,synopsis in sorted(common.items()): - log(' %-10s %s\n' % (cmd, synopsis)) - log('\n') - - log('Other available commands:\n') + log(' %-10s %s' % (cmd, synopsis)) + log('') + + log('Other available commands:') cmds = [] for c in sorted(os.listdir(cmdpath) + os.listdir(exepath)): if c.startswith('bup-') and c.find('.') < 0: @@ -58,12 +59,12 @@ def usage(msg=""): if cname not in common: cmds.append(c[4:]) log(columnate(cmds, ' ')) - log('\n') - + log("See 'bup help COMMAND' for more information on " + - "a specific command.\n") + "a specific command.") if msg: - log("\n%s\n" % msg) + log('') + log("%s" % msg) sys.exit(99) @@ -156,7 +157,7 @@ p = None forward_signals = True def handler(signum, frame): - debug1('\nbup: signal %d received\n' % signum) + debug1('bup: Signal %d received.' % signum) if not p or not forward_signals: return if signum != signal.SIGTSTP: @@ -190,7 +191,7 @@ try: forward_signals = False break except OSError, e: - log('%s: %s\n' % (subcmd[0], e)) + log('%s: %s' % (subcmd[0], e)) ret = 98 finally: if p and p.poll() == None: -- 2.39.2