Skip to content

Commit

Permalink
[getopts/getopts_long] Use GNU formatting for error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sideeffect42 committed Dec 30, 2023
1 parent 7128798 commit e372ead
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/getopts/getopts_long.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ in
OPTARG_LONG=${OPTARG_LONG#--}
;;
(*)
echo "option '--${__optstring%%[:?,]*}' doesn't allow an argument" >&2
echo "option \`--${__optstring%%[:?,]*}' doesn't allow an argument" >&2
;;
esac
: $((OPTIND_LONG+=1))
Expand Down Expand Up @@ -122,7 +122,7 @@ in
read -r "$2" <<-EOF
?
EOF
echo "option '$3' requires an argument" >&2
echo "option \`$3' requires an argument" >&2
;;
esac

Expand Down Expand Up @@ -159,7 +159,7 @@ in
OPTARG_LONG=${OPTARG_LONG#--}
;;
(*)
echo "unrecognized option '$3'" >&2
echo "unrecognized option \`$3'" >&2
;;
esac

Expand Down
6 changes: 3 additions & 3 deletions spec/getopts/getopts_long.spec
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Describe 'getopts/getopts_long'

The status should be success
The stdout should equal ''
The stderr should equal 'unrecognized option '\''--illegal'\'''
The stderr should equal 'unrecognized option `--illegal'\'''

The variable _opt should equal '?'
The variable OPTARG_LONG should be undefined
Expand Down Expand Up @@ -146,7 +146,7 @@ Describe 'getopts/getopts_long'

The status should be success
The stdout should equal ''
The stderr should equal 'option '\''--required'\'' requires an argument'
The stderr should equal 'option `--required'\'' requires an argument'

The variable _opt should equal '?'
The variable OPTARG_LONG should be undefined
Expand Down Expand Up @@ -233,7 +233,7 @@ Describe 'getopts/getopts_long'

The status should be success
The stdout should equal ''
The stderr should equal 'option '\''--flag'\'' doesn'\''t allow an argument'
The stderr should equal 'option `--flag'\'' doesn'\''t allow an argument'

The variable _opt should equal '?'
The variable OPTARG_LONG should be undefined
Expand Down

0 comments on commit e372ead

Please sign in to comment.