Commit 3fe9a965 authored by Seblu's avatar Seblu
Browse files

fix bad getpass removing history

parent bea530ff
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -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