From 30f4284b663ea18c421ed754a1d2102712b6fee0 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 8 Jul 2009 16:48:49 +0100 Subject: prosodyctl: Don't 'blugh' when ^C is pressed during reading passwords --- prosodyctl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/prosodyctl b/prosodyctl index 2557d865..8471e7ab 100755 --- a/prosodyctl +++ b/prosodyctl @@ -125,17 +125,21 @@ end local function getchar(n) os.execute("stty raw -echo"); - local char = io.read(n or 1); + local ok, char = pcall(io.read, n or 1); os.execute("stty sane"); - return char; + if ok then + return char; + end end local function getpass() os.execute("stty -echo"); - local pass = io.read("*l"); + local ok, pass = pcall(io.read, "*l"); os.execute("stty sane"); io.write("\n"); - return pass; + if ok then + return pass; + end end function show_yesno(prompt) -- cgit v1.2.3