Changeset

1500:56d05ba00169

prosodyctl: Don't 'blugh' when ^C is pressed during reading passwords
author Matthew Wild <mwild1@gmail.com>
date Wed, 08 Jul 2009 16:48:49 +0100
parents 1499:51e3e22b5316
children 1501:330b8437ac35
files prosodyctl
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/prosodyctl	Wed Jul 08 16:38:46 2009 +0100
+++ b/prosodyctl	Wed Jul 08 16:48:49 2009 +0100
@@ -125,17 +125,21 @@
 
 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)