aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlin Mr <almr.oss@outlook.com>2024-05-03 07:22:57 +0000
committerFlorian Fischer <florian.fischer@muhq.space>2024-05-03 16:43:31 +0200
commitf6919f7f59b8f9f25c7b8c08df4d6f1c2c1850dd (patch)
treead870bbca157068597ef14d82d95837999daa24a
parent064717fcc800d9ca94366745610305d12a5532a4 (diff)
downloadvis-lockfiles-f6919f7f59b8f9f25c7b8c08df4d6f1c2c1850dd.tar.gz
vis-lockfiles-f6919f7f59b8f9f25c7b8c08df4d6f1c2c1850dd.zip
init.lua: simplify 'yes' detection
-rw-r--r--init.lua15
1 files changed, 5 insertions, 10 deletions
diff --git a/init.lua b/init.lua
index 5c85818..2644eea 100644
--- a/init.lua
+++ b/init.lua
@@ -34,23 +34,18 @@ end
local function confirm(path)
local choices = 'no\nyes'
local prompt = path .. ' exists. Edit anyway:'
- local cmd = 'printf "' .. choices .. '" | vis-menu -b -p \'' .. prompt .. '\''
+ local cmd = 'printf %s \'' .. choices .. '\' | vis-menu -b -p \'' .. prompt .. '\''
- local choice = nil
-- local status, output = vis:pipe(nil, {start = 0, finish = 0}, cmd)
local menu = assert(io.popen(cmd))
local output = menu:read('*a')
local _, _, status = menu:close()
+ vis:redraw()
+
if status == 0 then
- -- trim newline from selection
- if output:sub(-1) == '\n' then
- choice = output:sub(1, -2)
- else
- choice = output
- end
+ return 'yes' == output:sub(1, 3)
end
- vis:redraw()
- return choice == 'yes'
+ return false
end
local created_locks = {}