]> arthur.barton.de Git - bup.git/commitdiff
Fix formatting of usage message (especially newlines)
authorAlexander Barton <alex@barton.de>
Wed, 31 Dec 2014 17:06:28 +0000 (18:06 +0100)
committerAlexander Barton <alex@barton.de>
Wed, 31 Dec 2014 17:48:56 +0000 (18:48 +0100)
Bug introduced by commit 82816c9, "Don't include newline (NL) character
in exception messages". Oops.

Signed-off-by: Alexander Barton <alex@barton.de>
lib/bup/options.py
main.py

index a15220a92da5680d66bde2b854c8dc4696ecfaf5..65702e2a80c8629d530ea5e1d41938e0195a9f23 100644 (file)
@@ -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 45a0e8a14ae30b62013d0fe187ff94f0348c35b2..0a63de2806dc4478adfa684989a44aa6a776f73a 100755 (executable)
--- 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] '
-        '<command> [options...]\n\n')
+        '<command> [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: