]> arthur.barton.de Git - bup.git/commitdiff
cmd/ftp: only import readline if necessary.
authorAvery Pennarun <apenwarr@gmail.com>
Fri, 9 Jul 2010 17:47:16 +0000 (13:47 -0400)
committerAvery Pennarun <apenwarr@gmail.com>
Fri, 9 Jul 2010 17:57:20 +0000 (13:57 -0400)
Apparently on some systems (Mandriva and Slackware at least), importing
the readline library can print some escape sequences to stdout, which screws
things up with the unit tests that run 'bup ftp "cat filename"' and expect
it to be the right data.

Thanks to Eduardo Kienetz for noticing and helping to track down the problem
since I couldn't reproduce it.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
cmd/ftp-cmd.py

index c6f26af7700eb1eab8be62317416cb09fbcc8913..0dd825ab3568f7c38712d290be26987fbe7d11c4 100755 (executable)
@@ -3,13 +3,6 @@ import sys, os, re, stat, fnmatch
 from bup import options, git, shquote, vfs
 from bup.helpers import *
 
-try:
-    import readline
-except ImportError:
-    log('* readline module not available: line editing disabled.\n')
-    readline = None
-
-
 def node_name(text, n):
     if stat.S_ISDIR(n.mode):
         return '%s/' % text
@@ -116,7 +109,7 @@ def completer(text, state):
 
 
 optspec = """
-bup ftp
+bup ftp [commands...]
 """
 o = options.Options('bup ftp', optspec)
 (opt, flags, extra) = o.parse(sys.argv[1:])
@@ -130,6 +123,12 @@ rv = 0
 if extra:
     lines = extra
 else:
+    try:
+        import readline
+    except ImportError:
+        log('* readline module not available: line editing disabled.\n')
+        readline = None
+
     if readline:
         readline.set_completer_delims(' \t\n\r/')
         readline.set_completer(completer)