1
0
Fork 0
forked from glenux/mfm

fix: improve fzf error handling

This commit is contained in:
Glenn Y. Rolland 2023-10-24 16:00:12 +02:00
parent 67cd9ae964
commit cef669e15e

View file

@ -11,8 +11,17 @@ module GX
error = STDERR
process = Process.new("fzf", ["--ansi"], input: input, output: output, error: error)
unless process.wait.success?
STDERR.puts "Error executing fzf: #{error.to_s.strip}".colorize(:red)
status = process.wait
case status.exit_code
when 0
when 1
STDERR.puts "No match".colorize(:red)
exit(1)
when 130
STDERR.puts "Interrupted".colorize(:red)
exit(1)
else # includes retcode = 2 (error)
STDERR.puts "Error executing fzf: #{error.to_s.strip} (#{status.exit_code})".colorize(:red)
exit(1)
end