From 3fe9a965c4c87963bf6c639137f53063ffb96177 Mon Sep 17 00:00:00 2001
From: Seblu <sebastien.luttringer@smartjog.com>
Date: Thu, 10 Feb 2011 16:19:48 +0100
Subject: [PATCH] fix bad getpass removing history

---
 cccli/printer.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/cccli/printer.py b/cccli/printer.py
index 9d1ef3f..cdac2f8 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
-- 
GitLab