]> arthur.barton.de Git - bup.git/commitdiff
ftp: handle lack of readline in input
authorJohannes Berg <johannes@sipsolutions.net>
Tue, 28 Jul 2020 20:28:11 +0000 (22:28 +0200)
committerRob Browning <rlb@defaultvalue.org>
Wed, 29 Jul 2020 00:53:10 +0000 (19:53 -0500)
If we don't have readline, print our prompt and read a line
from stdin instead.

Reported-by: Eric Waguespack <eric.w@guespack.com>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
lib/cmd/ftp-cmd.py

index 8e05fa831d232d3021dd8a4143e8f52567c8cccf..02a6fecef014609806e827c0c3a0b7aa222a6c1e 100755 (executable)
@@ -55,11 +55,20 @@ def write_to_file(inf, outf):
 def inputiter():
     if os.isatty(stdin.fileno()):
         while 1:
-            try:
-                yield _helpers.readline(b'bup> ')
-            except EOFError:
-                print()  # Clear the line for the terminal's next prompt
-                break
+            if hasattr(_helpers, 'readline'):
+                try:
+                    yield _helpers.readline(b'bup> ')
+                except EOFError:
+                    print()  # Clear the line for the terminal's next prompt
+                    break
+            else:
+                out.write(b'bup> ')
+                out.flush()
+                read_line = stdin.readline()
+                if not read_line:
+                    print('')
+                    break
+                yield read_line
     else:
         for line in stdin:
             yield line