Skip to content

Commit

Permalink
Fixes -f-flag not to be interpreted as -f --flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ko1nksm committed Aug 10, 2024
1 parent 0205dda commit 68a7daf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixes Makefile
- Fixes -f- not to be interpreted as -f --
- Fixes -f-flag not to be interpreted as -f --flag

## [3.3.1] - 2024-07-30

Expand Down
2 changes: 1 addition & 1 deletion lib/getoptions_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ getoptions() {
[ "$_alt" ] || {
[ "$_opts" ] && _op "-[$_opts]?*" "" ";;"
[ ! "$_flags" ] || _op "-[$_flags]?*" - "OPTARG= ;;" \
'[ "$2" = -- ] && set -- "$1" unknown -- && '"$_rest=x; "
'case $2 in --*) set -- "$1" unknown "$2" && '"$_rest=x; esac;"
}
[ "$_plus" ] && {
[ "$_nflags" ] && _op "+[$_nflags]?*" + "unset OPTARG ;;"
Expand Down
9 changes: 9 additions & 0 deletions spec/getoptions_base_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ Describe "getoptions()"
End
End

Context "when the combined short option contains -"
parser_definition() { setup ARGS; flag FLAG -f --flag; }
It "displays error"
When run parse -f-flag
The stderr should eq "Unrecognized option: --flag"
The status should be failure
End
End

Context "when specified unknown long option"
parser_definition() { setup ARGS; }
It "displays error"
Expand Down

0 comments on commit 68a7daf

Please sign in to comment.