diff --git a/cccli/printer.py b/cccli/printer.py index 9d1ef3f7e89f983c1cee3b63a28542ce7442befb..cdac2f8e0fac4ce9ede291d81b0a4503950ba166 100644 --- a/cccli/printer.py +++ b/cccli/printer.py @@ -105,7 +105,7 @@ class Printer(object): if self.readline is not None: self.out(message, fd, nl) - def getline(self, prompt, history=True): + def getline(self, prompt): '''Read a line from stdin''' try: s = raw_input(prompt) @@ -115,8 +115,6 @@ class Printer(object): raise except Exception as e: raise cliError(str(e)) - if not history and s: - self.history.removelast() return s def getpass(self, prompt): @@ -127,11 +125,14 @@ class Printer(object): old = termios.tcgetattr(fd) new = termios.tcgetattr(fd) new[3] = new[3] & ~termios.ECHO + h = list(self.history) + self.history.clear() try: termios.tcsetattr(fd, termios.TCSADRAIN, new) - passwd = raw_input(prompt) + passwd = self.getline(prompt) finally: termios.tcsetattr(fd, termios.TCSADRAIN, old) + self.history.load(h) sys.stdout.write(os.linesep) sys.stdout.flush() return passwd