From b4ff342b0a284a8e58837ec4951b15d6d33db397 Mon Sep 17 00:00:00 2001 From: n1nj4sec Date: Wed, 25 May 2016 22:36:58 +0200 Subject: [PATCH] *nix interactive_shell module escape character issues fix (with history and arrows) --- pupy/modules/interactive_shell.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pupy/modules/interactive_shell.py b/pupy/modules/interactive_shell.py index 049b3acf..3031621c 100644 --- a/pupy/modules/interactive_shell.py +++ b/pupy/modules/interactive_shell.py @@ -82,7 +82,11 @@ class InteractiveShell(PupyModule): while True: r, w, x = select.select([sys.stdin], [], [], 0) if sys.stdin in r: - input_buf+=sys.stdin.read(1) + last_input=sys.stdin.read(1) + if last_input=="\x1b": # in case we read the escape character, we read stdin again because mysteriously, the select won't unlock before getting another character again + last_input+=sys.stdin.read(2) + + input_buf+=last_input elif input_buf: self.ps.write(input_buf) input_buf=b""