From 5ac3821c0f1fbd6a1b1742e91ffd556cd1116041 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 28 Jul 2020 22:28:11 +0200 Subject: [PATCH] ftp: handle lack of readline in input If we don't have readline, print our prompt and read a line from stdin instead. Reported-by: Eric Waguespack Signed-off-by: Johannes Berg --- lib/cmd/ftp-cmd.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/cmd/ftp-cmd.py b/lib/cmd/ftp-cmd.py index 8e05fa8..02a6fec 100755 --- a/lib/cmd/ftp-cmd.py +++ b/lib/cmd/ftp-cmd.py @@ -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 -- 2.39.2