From c37155d5edc9b4ebd51071f299583d50224aa834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Thu, 27 Nov 2008 11:27:29 +0000 Subject: [PATCH] When PiSi CLI asks you a question, it doesn't flush its input buffer, causing characters typed before the question prompt to be handled like the answer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Example: $ sudo pisi it clisp -vd (I mistakenly typed another character or hitted enter a second time, now stdin contains something..) aDEBUG: InstallDB initialized in 0.213829994202. (NOTE THE 'a' CHARACTER) DEBUG: RepoDB initialized in 0.000118017196655. DEBUG: ComponentDB initialized in 0.55585193634. digraph G { } DEBUG: PackageDB initialized in 1.42305612564. DEBUG: checking libsigsegv DEBUG: checking ffcall DEBUG: checking libXpm digraph G { ffcall[ label = "ffcall(1.10,1)" ]; clisp[ label = "clisp(2.47,6)" ]; clisp -> ffcall; } Bağımlılıkları sağlamak için bu paketler verilen sırada kurulacaktır: ffcall clisp Paket(ler)in toplam boyu: 2.66 MB Bağımlılıklar yüzünden ek paketler var. Devam etmek istiyor musunuz? (evet/hayır)e $ Eventhough I typed 'e' to the question, because of the 'a' character found in stdin, PiSi thinks that the user answered with an 'a'. -- This is now fixed by flushing the input buffer just before a confirmation question. --- pisi/cli/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pisi/cli/__init__.py b/pisi/cli/__init__.py index a1b66ebc..afb708a8 100644 --- a/pisi/cli/__init__.py +++ b/pisi/cli/__init__.py @@ -108,9 +108,10 @@ class CLI(pisi.ui.UI): if ctx.config.options and ctx.config.options.yes_all: return True while True: - import re + import re, tty yesexpr = re.compile(locale.nl_langinfo(locale.YESEXPR)) + tty.tcflush(sys.stdin.fileno(), 0) prompt = msg + pisi.util.colorize(_(' (yes/no)'), 'red') s = raw_input(prompt.encode('utf-8')) if yesexpr.search(s):