Skip to content
Snippets Groups Projects
Commit 3fe9a965 authored by Seblu's avatar Seblu
Browse files

fix bad getpass removing history

parent bea530ff
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment