Comparison

util/prosodyctl.lua @ 7457:5e18416881bb

util.prosodyctl: Handle os.execute in Lua 5.2 returning true when command terminates successfully
author Kim Alvefur <zash@zash.se>
date Thu, 23 Jun 2016 21:07:48 +0200
parent 7262:751a4832adb4
child 8123:bd591c5fc1bf
comparison
equal deleted inserted replaced
7455:82d8c11ab0cb 7457:5e18416881bb
42 end 42 end
43 43
44 local function getchar(n) 44 local function getchar(n)
45 local stty_ret = os.execute("stty raw -echo 2>/dev/null"); 45 local stty_ret = os.execute("stty raw -echo 2>/dev/null");
46 local ok, char; 46 local ok, char;
47 if stty_ret == 0 then 47 if stty_ret == true or stty_ret == 0 then
48 ok, char = pcall(io.read, n or 1); 48 ok, char = pcall(io.read, n or 1);
49 os.execute("stty sane"); 49 os.execute("stty sane");
50 else 50 else
51 ok, char = pcall(io.read, "*l"); 51 ok, char = pcall(io.read, "*l");
52 if ok then 52 if ok then