Comparison

prosodyctl @ 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
parent 1499:51e3e22b5316
child 1501:330b8437ac35
comparison
equal deleted inserted replaced
1499:51e3e22b5316 1500:56d05ba00169
123 end 123 end
124 end 124 end
125 125
126 local function getchar(n) 126 local function getchar(n)
127 os.execute("stty raw -echo"); 127 os.execute("stty raw -echo");
128 local char = io.read(n or 1); 128 local ok, char = pcall(io.read, n or 1);
129 os.execute("stty sane"); 129 os.execute("stty sane");
130 return char; 130 if ok then
131 return char;
132 end
131 end 133 end
132 134
133 local function getpass() 135 local function getpass()
134 os.execute("stty -echo"); 136 os.execute("stty -echo");
135 local pass = io.read("*l"); 137 local ok, pass = pcall(io.read, "*l");
136 os.execute("stty sane"); 138 os.execute("stty sane");
137 io.write("\n"); 139 io.write("\n");
138 return pass; 140 if ok then
141 return pass;
142 end
139 end 143 end
140 144
141 function show_yesno(prompt) 145 function show_yesno(prompt)
142 io.write(prompt, " "); 146 io.write(prompt, " ");
143 local choice = getchar():lower(); 147 local choice = getchar():lower();