Skip to content

Commit

Permalink
bin/ascii85: Bail with exit status 1 when command-line parsing fails
Browse files Browse the repository at this point in the history
  • Loading branch information
DataWraith committed May 4, 2024
1 parent 687bf9c commit c98433c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bin/ascii85
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ ARGV.options do |opts|
end
end

# When opt_parse fails, it will raise an Exception that prints an error message,
# but the program will continue running. However, @options[:file] will not be
# set, so we can detect this condition and simply exit with an error status
# code while OptParse prints out the error message.
if @options[:file].nil?
exit 1
end

if @options[:file] == '-'
@input = $stdin.binmode.read
else
Expand Down

0 comments on commit c98433c

Please sign in to comment.