Skip to content

Commit

Permalink
Behave well when interrupted and when used in a pipe that gets closed
Browse files Browse the repository at this point in the history
  • Loading branch information
gettalong committed Dec 8, 2020
1 parent 7581561 commit 3b2a49c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/cmdparse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,10 @@ def parse(argv = ARGV) # :yields: level, command_name
@main_command.commands['help'].execute(*@current_command.command_chain.map(&:name))
end
exit(64) # FreeBSD standard exit error for "command was used incorrectly"
rescue Interrupt
exit(128 + 2)
rescue Errno::EPIPE
# Behave well when used in a pipe
ensure
@current_command = nil
end
Expand Down

0 comments on commit 3b2a49c

Please sign in to comment.