Skip to content

Commit 833b9f2

Browse files
committed
Fixed unbound argument when determining OPTSPEC override
1 parent cfaae36 commit 833b9f2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/getopts_long.bash

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ getopts_long() {
3737
# Sanitize and normalize short optspec
3838
optspec_short="${optspec_short//-:}"
3939
optspec_short="${optspec_short//-}"
40-
[[ "${!OPTIND:0:2}" == "--" ]] && optspec_short+='-:'
40+
if [[ -n "${!OPTIND:-}" && "${!OPTIND:0:2}" == "--" ]]; then
41+
optspec_short+='-:'
42+
fi
43+
4144

4245
builtin getopts -- "${optspec_short}" "${optvar}" "${@}" || return ${?}
4346
[[ "${!optvar}" == '-' ]] || return 0

0 commit comments

Comments
 (0)