util.human.io: Fix handling of os.execute() return values in Lua 5.2+
authorKim Alvefur <zash@zash.se>
Thu, 20 Oct 2022 17:35:01 +0200
changeset 12787 d513e4bd4928
parent 12786 8815d3090928
child 12788 3b9de8dd71a3
util.human.io: Fix handling of os.execute() return values in Lua 5.2+ Wrong part of Lua 5.1 compat removed in 0f4feaf9ca64
util/human/io.lua
--- a/util/human/io.lua	Thu Oct 20 16:50:12 2022 +0200
+++ b/util/human/io.lua	Thu Oct 20 17:35:01 2022 +0200
@@ -8,7 +8,7 @@
 local function getchar(n)
 	local stty_ret = os.execute("stty raw -echo 2>/dev/null");
 	local ok, char;
-	if stty_ret == true or stty_ret == 0 then
+	if stty_ret then
 		ok, char = pcall(io.read, n or 1);
 		os.execute("stty sane");
 	else
@@ -31,11 +31,11 @@
 
 local function getpass()
 	local stty_ret = os.execute("stty -echo 2>/dev/null");
-	if stty_ret ~= 0 then
+	if not stty_ret then
 		io.write("\027[08m"); -- ANSI 'hidden' text attribute
 	end
 	local ok, pass = pcall(io.read, "*l");
-	if stty_ret == 0 then
+	if stty_ret then
 		os.execute("stty sane");
 	else
 		io.write("\027[00m");