diff options
| author | Alin Mr <almr.oss@outlook.com> | 2024-05-03 07:22:57 +0000 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2024-05-03 16:43:31 +0200 |
| commit | f6919f7f59b8f9f25c7b8c08df4d6f1c2c1850dd (patch) | |
| tree | ad870bbca157068597ef14d82d95837999daa24a /init.lua | |
| parent | 064717fcc800d9ca94366745610305d12a5532a4 (diff) | |
| download | vis-lockfiles-f6919f7f59b8f9f25c7b8c08df4d6f1c2c1850dd.tar.gz vis-lockfiles-f6919f7f59b8f9f25c7b8c08df4d6f1c2c1850dd.zip | |
init.lua: simplify 'yes' detection
Diffstat (limited to 'init.lua')
| -rw-r--r-- | init.lua | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -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 = {} |
