Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensures the handling of OPTARG is consistent with Bash’s getopts #30

Merged
merged 8 commits into from
Dec 14, 2024
1 change: 1 addition & 0 deletions lib/getopts_long.bash
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ getopts_long() {
fi
elif [[ " ${optspec_long} " == *" ${!optvar} "* ]]; then
unset OPTARG
declare -g OPTARG
else
# Invalid option
if [[ "${optspec_short:0:1}" == ':' ]]; then
Expand Down
24 changes: 12 additions & 12 deletions test/bats/github_15a.bats
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ load ../test_helper
'--toggle-- --toggle user_arg' \
'1{/^toggle triggered/d}' \
'/^INVALID OPTION/d'
expect "${bash_getopts[1]}" == 'toggle triggered -- OPTARG is unset'
expect "${bash_getopts[2]}" == 'INVALID OPTION -- OPTARG=-'
expect "${bash_getopts[3]}" == 'INVALID OPTION -- OPTARG=-'
expect "${bash_getopts[4]}" == 'toggle triggered -- OPTARG is unset'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG=toggle--'
expect "${getopts_long[2]}" == 'toggle triggered -- OPTARG is unset'
expect "${bash_getopts[2]}" == 'INVALID OPTION -- OPTARG="-"'
expect "${bash_getopts[3]}" == 'INVALID OPTION -- OPTARG="-"'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG="toggle--"'
expect "${bash_getopts[1]}" == 'toggle triggered -- OPTARG'
expect "${bash_getopts[4]}" == 'toggle triggered -- OPTARG'
expect "${getopts_long[2]}" == 'toggle triggered -- OPTARG'
}
@test "${FEATURE}: long toggle, verbose" {
compare '-t-- -t user_arg' \
Expand All @@ -52,12 +52,12 @@ load ../test_helper
'5{/^INVALID OPTION or MISSING ARGUMENT/d}' \
's/getopts[[:alpha:]_-]*/GETOPTS-NORMALISED/' \
's/(illegal option --) (-|toggle--)/\1 TOGGLE-NORMALISED/'
expect "${bash_getopts[1]}" == 'toggle triggered -- OPTARG is unset'
expect "${bash_getopts[1]}" == 'toggle triggered -- OPTARG'
expect "${bash_getopts[2]}" =~ 'getopts-verbose: illegal option -- -$'
expect "${bash_getopts[4]}" =~ 'getopts-verbose: illegal option -- -$'
expect "${bash_getopts[6]}" == 'toggle triggered -- OPTARG is unset'
expect "${bash_getopts[6]}" == 'toggle triggered -- OPTARG'
expect "${getopts_long[1]}" =~ 'getopts_long-verbose: illegal option -- toggle--$'
expect "${getopts_long[3]}" == 'toggle triggered -- OPTARG is unset'
expect "${getopts_long[3]}" == 'toggle triggered -- OPTARG'
}

# Both implementations should see:
Expand All @@ -82,14 +82,14 @@ load ../test_helper
compare '-o-- -t user_arg' \
'--option-- --toggle user_arg' \
'1{/(option supplied|INVALID OPTION)/d}'
expect "${bash_getopts[1]}" == 'option supplied -- OPTARG=--'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG=option--'
expect "${bash_getopts[1]}" == 'option supplied -- OPTARG="--"'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG="option--"'
}
@test "${FEATURE}: long option, verbose" {
compare '-o-- -t user_arg' \
'--option-- --toggle user_arg' \
'1{/(option supplied|illegal option)/d}' \
'2{/^INVALID OPTION or MISSING ARGUMENT/d}'
expect "${bash_getopts[1]}" == 'option supplied -- OPTARG=--'
expect "${bash_getopts[1]}" == 'option supplied -- OPTARG="--"'
expect "${getopts_long[1]}" =~ "getopts_long-verbose: illegal option -- option--$"
}
24 changes: 12 additions & 12 deletions test/bats/github_15b.bats
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ export GETOPTS_LONG_TEST_BIN='getopts_long-shortspec_with_dash'
'--toggle-- --toggle user_arg' \
'1{/^toggle triggered/d}' \
'/^INVALID OPTION/d'
expect "${bash_getopts[1]}" == 'toggle triggered -- OPTARG is unset'
expect "${bash_getopts[2]}" == 'INVALID OPTION -- OPTARG=-'
expect "${bash_getopts[3]}" == 'INVALID OPTION -- OPTARG=-'
expect "${bash_getopts[4]}" == 'toggle triggered -- OPTARG is unset'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG=toggle--'
expect "${getopts_long[2]}" == 'toggle triggered -- OPTARG is unset'
expect "${bash_getopts[2]}" == 'INVALID OPTION -- OPTARG="-"'
expect "${bash_getopts[3]}" == 'INVALID OPTION -- OPTARG="-"'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG="toggle--"'
expect "${bash_getopts[1]}" == 'toggle triggered -- OPTARG'
expect "${bash_getopts[4]}" == 'toggle triggered -- OPTARG'
expect "${getopts_long[2]}" == 'toggle triggered -- OPTARG'
}
@test "${FEATURE}: long toggle, verbose" {
compare '-t-- -t user_arg' \
Expand All @@ -55,12 +55,12 @@ export GETOPTS_LONG_TEST_BIN='getopts_long-shortspec_with_dash'
'5{/^INVALID OPTION or MISSING ARGUMENT/d}' \
's/getopts[[:alpha:]_-]*/GETOPTS-NORMALISED/' \
's/(illegal option --) (-|toggle--)/\1 TOGGLE-NORMALISED/'
expect "${bash_getopts[1]}" == 'toggle triggered -- OPTARG is unset'
expect "${bash_getopts[1]}" == 'toggle triggered -- OPTARG'
expect "${bash_getopts[2]}" =~ 'getopts-verbose: illegal option -- -$'
expect "${bash_getopts[4]}" =~ 'getopts-verbose: illegal option -- -$'
expect "${bash_getopts[6]}" == 'toggle triggered -- OPTARG is unset'
expect "${bash_getopts[6]}" == 'toggle triggered -- OPTARG'
expect "${getopts_long[1]}" =~ 'getopts_long-\w+-verbose: illegal option -- toggle--$'
expect "${getopts_long[3]}" == 'toggle triggered -- OPTARG is unset'
expect "${getopts_long[3]}" == 'toggle triggered -- OPTARG'
}

# Both implementations should see:
Expand All @@ -85,14 +85,14 @@ export GETOPTS_LONG_TEST_BIN='getopts_long-shortspec_with_dash'
compare '-o-- -t user_arg' \
'--option-- --toggle user_arg' \
'1{/(option supplied|INVALID OPTION)/d}'
expect "${bash_getopts[1]}" == 'option supplied -- OPTARG=--'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG=option--'
expect "${bash_getopts[1]}" == 'option supplied -- OPTARG="--"'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG="option--"'
}
@test "${FEATURE}: long option, verbose" {
compare '-o-- -t user_arg' \
'--option-- --toggle user_arg' \
'1{/(option supplied|illegal option)/d}' \
'2{/^INVALID OPTION or MISSING ARGUMENT/d}'
expect "${bash_getopts[1]}" == 'option supplied -- OPTARG=--'
expect "${bash_getopts[1]}" == 'option supplied -- OPTARG="--"'
expect "${getopts_long[1]}" =~ "getopts_long-\w+-verbose: illegal option -- option--$"
}
4 changes: 2 additions & 2 deletions test/bats/github_26b.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export GETOPTS_LONG_TEST_BIN='getopts_long-longspec_with_dash_colon'
compare '-z' \
'---zz' \
'/^INVALID OPTION/d'
expect "${bash_getopts[1]}" == 'INVALID OPTION -- OPTARG=z'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG=-zz'
expect "${bash_getopts[1]}" == 'INVALID OPTION -- OPTARG="z"'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG="-zz"'
}
@test "${FEATURE}: option with adjacent value, verbose" {
compare '-z' \
Expand Down
12 changes: 6 additions & 6 deletions test/bats/invalid_arguments.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ load ../test_helper
compare '-i' \
'--invalid' \
'/^INVALID OPTION -- /d'
expect "${bash_getopts[1]}" == 'INVALID OPTION -- OPTARG=i'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG=invalid'
expect "${bash_getopts[1]}" == 'INVALID OPTION -- OPTARG="i"'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG="invalid"'
}
@test "${FEATURE}: long option, verbose" {
compare '-i' \
Expand All @@ -41,8 +41,8 @@ load ../test_helper
compare '-i user_arg' \
'--invalid user_arg' \
'/^INVALID OPTION -- /d'
expect "${bash_getopts[1]}" == 'INVALID OPTION -- OPTARG=i'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG=invalid'
expect "${bash_getopts[1]}" == 'INVALID OPTION -- OPTARG="i"'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG="invalid"'
}
@test "${FEATURE}: long option, extra arguments, verbose" {
compare '-i user_arg' \
Expand All @@ -68,8 +68,8 @@ load ../test_helper
compare '-i -- user_arg' \
'--invalid -- user_arg' \
'/^INVALID OPTION -- /d'
expect "${bash_getopts[1]}" == 'INVALID OPTION -- OPTARG=i'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG=invalid'
expect "${bash_getopts[1]}" == 'INVALID OPTION -- OPTARG="i"'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG="invalid"'
expect "${getopts_long[6]}" == '$@: user_arg'
}
@test "${FEATURE}: long option, terminator, extra arguments, verbose" {
Expand Down
26 changes: 13 additions & 13 deletions test/bats/option_supplied.bats
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,27 @@ load ../test_helper
@test "${FEATURE}: short option, multiple same arguments, silent" {
compare '-o user_val1 -o user_val2' \
'-o user_val1 -o user_val2'
expect "${getopts_long[1]}" == 'option supplied -- OPTARG=user_val1'
expect "${getopts_long[2]}" == 'option supplied -- OPTARG=user_val2'
expect "${getopts_long[1]}" == 'option supplied -- OPTARG="user_val1"'
expect "${getopts_long[2]}" == 'option supplied -- OPTARG="user_val2"'
}
@test "${FEATURE}: short option, multiple same arguments, verbose" {
compare '-o user_val1 -o user_val2' \
'-o user_val1 -o user_val2'
expect "${getopts_long[1]}" == 'option supplied -- OPTARG=user_val1'
expect "${getopts_long[2]}" == 'option supplied -- OPTARG=user_val2'
expect "${getopts_long[1]}" == 'option supplied -- OPTARG="user_val1"'
expect "${getopts_long[2]}" == 'option supplied -- OPTARG="user_val2"'
}

@test "${FEATURE}: long option, multiple same arguments, silent" {
compare '-o user_val1 -o user_val2' \
'--option user_val1 --option user_val2'
expect "${getopts_long[1]}" == 'option supplied -- OPTARG=user_val1'
expect "${getopts_long[2]}" == 'option supplied -- OPTARG=user_val2'
expect "${getopts_long[1]}" == 'option supplied -- OPTARG="user_val1"'
expect "${getopts_long[2]}" == 'option supplied -- OPTARG="user_val2"'
}
@test "${FEATURE}: long option, multiple same arguments, verbose" {
compare '-o user_val1 -o user_val2' \
'--option user_val1 --option user_val2'
expect "${getopts_long[1]}" == 'option supplied -- OPTARG=user_val1'
expect "${getopts_long[2]}" == 'option supplied -- OPTARG=user_val2'
expect "${getopts_long[1]}" == 'option supplied -- OPTARG="user_val1"'
expect "${getopts_long[2]}" == 'option supplied -- OPTARG="user_val2"'
}

# terminator followed by options
Expand Down Expand Up @@ -134,8 +134,8 @@ load ../test_helper
compare '-o' \
'--option' \
'/^MISSING ARGUMENT -- /d'
expect "${bash_getopts[1]}" == 'MISSING ARGUMENT -- OPTARG=o'
expect "${getopts_long[1]}" == 'MISSING ARGUMENT -- OPTARG=option'
expect "${bash_getopts[1]}" == 'MISSING ARGUMENT -- OPTARG="o"'
expect "${getopts_long[1]}" == 'MISSING ARGUMENT -- OPTARG="option"'
}
@test "${FEATURE}: long option, missing value, verbose" {
compare '-o' \
Expand Down Expand Up @@ -198,8 +198,8 @@ load ../test_helper
compare '-ouser_val' \
'--optionuser_val' \
'1d'
expect "${bash_getopts[1]}" == 'option supplied -- OPTARG=user_val'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG=optionuser_val'
expect "${bash_getopts[1]}" == 'option supplied -- OPTARG="user_val"'
expect "${getopts_long[1]}" == 'INVALID OPTION -- OPTARG="optionuser_val"'

}

Expand All @@ -208,6 +208,6 @@ load ../test_helper
'--optionuser_val' \
'1d' \
'2{/^INVALID OPTION or MISSING ARGUMENT/d}'
expect "${bash_getopts[1]}" == 'option supplied -- OPTARG=user_val'
expect "${bash_getopts[1]}" == 'option supplied -- OPTARG="user_val"'
expect "${getopts_long[1]}" =~ 'getopts_long-verbose: illegal option -- optionuser_val'
}
8 changes: 4 additions & 4 deletions test/bats/toggle_triggered.bats
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,26 @@ load ../test_helper
compare '-t -t' \
'-t -t'
expect "${getopts_long[1]}" == "${getopts_long[2]}"
expect "${getopts_long[1]}" == 'toggle triggered -- OPTARG is unset'
expect "${getopts_long[1]}" == 'toggle triggered -- OPTARG'
}
@test "${FEATURE}: short option, multiple same arguments, verbose" {
compare '-t -t' \
'-t -t'
expect "${getopts_long[1]}" == "${getopts_long[2]}"
expect "${getopts_long[1]}" == 'toggle triggered -- OPTARG is unset'
expect "${getopts_long[1]}" == 'toggle triggered -- OPTARG'
}

@test "${FEATURE}: long option, multiple same arguments, silent" {
compare '-t -t' \
'--toggle --toggle'
expect "${getopts_long[1]}" == "${getopts_long[2]}"
expect "${getopts_long[1]}" == 'toggle triggered -- OPTARG is unset'
expect "${getopts_long[1]}" == 'toggle triggered -- OPTARG'
}
@test "${FEATURE}: long option, multiple same arguments, verbose" {
compare '-t -t' \
'--toggle --toggle'
expect "${getopts_long[1]}" == "${getopts_long[2]}"
expect "${getopts_long[1]}" == 'toggle triggered -- OPTARG is unset'
expect "${getopts_long[1]}" == 'toggle triggered -- OPTARG'
}

# terminator followed by options
Expand Down
20 changes: 10 additions & 10 deletions test/bats/value_supplied.bats
Original file line number Diff line number Diff line change
Expand Up @@ -87,31 +87,31 @@ load ../test_helper
@test "${FEATURE}: short option, multiple same arguments, silent" {
compare '-v user_val1 -v user_val2' \
'-v user_val1 -v user_val2'
expect "${getopts_long[1]}" == 'value supplied -- OPTARG=user_val1'
expect "${getopts_long[2]}" == 'value supplied -- OPTARG=user_val2'
expect "${getopts_long[1]}" == 'value supplied -- OPTARG="user_val1"'
expect "${getopts_long[2]}" == 'value supplied -- OPTARG="user_val2"'
}
@test "${FEATURE}: short option, multiple same arguments, verbose" {
compare '-v user_val1 -v user_val2' \
'-v user_val1 -v user_val2'
expect "${getopts_long[1]}" == 'value supplied -- OPTARG=user_val1'
expect "${getopts_long[2]}" == 'value supplied -- OPTARG=user_val2'
expect "${getopts_long[1]}" == 'value supplied -- OPTARG="user_val1"'
expect "${getopts_long[2]}" == 'value supplied -- OPTARG="user_val2"'
}

@test "${FEATURE}: long option, multiple same arguments, silent" {
compare '-v user_val1 -v user_val2' \
'--variable=user_val1 --variable=user_val2' \
'/^OPTIND: /d'
expect "${getopts_long[1]}" == 'value supplied -- OPTARG=user_val1'
expect "${getopts_long[2]}" == 'value supplied -- OPTARG=user_val2'
expect "${getopts_long[1]}" == 'value supplied -- OPTARG="user_val1"'
expect "${getopts_long[2]}" == 'value supplied -- OPTARG="user_val2"'
expect "${bash_getopts[6]}" == 'OPTIND: 5'
expect "${getopts_long[6]}" == 'OPTIND: 3'
}
@test "${FEATURE}: long option, multiple same arguments, verbose" {
compare '-v user_val1 -v user_val2' \
'--variable=user_val1 --variable=user_val2' \
'/^OPTIND: /d'
expect "${getopts_long[1]}" == 'value supplied -- OPTARG=user_val1'
expect "${getopts_long[2]}" == 'value supplied -- OPTARG=user_val2'
expect "${getopts_long[1]}" == 'value supplied -- OPTARG="user_val1"'
expect "${getopts_long[2]}" == 'value supplied -- OPTARG="user_val2"'
expect "${bash_getopts[6]}" == 'OPTIND: 5'
expect "${getopts_long[6]}" == 'OPTIND: 3'
}
Expand Down Expand Up @@ -158,8 +158,8 @@ load ../test_helper
compare '-v' \
'--variable' \
'/^MISSING ARGUMENT -- /d'
expect "${bash_getopts[1]}" == 'MISSING ARGUMENT -- OPTARG=v'
expect "${getopts_long[1]}" == 'MISSING ARGUMENT -- OPTARG=variable'
expect "${bash_getopts[1]}" == 'MISSING ARGUMENT -- OPTARG="v"'
expect "${getopts_long[1]}" == 'MISSING ARGUMENT -- OPTARG="variable"'
}
@test "${FEATURE}: long option, missing value, verbose" {
compare '-v' \
Expand Down
2 changes: 1 addition & 1 deletion test/bin/getopts-silent
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ while getopts ":to:v:" OPTKEY; do
;;
esac
printf ' -- '
[[ -z "${OPTARG+SET}" ]] && echo 'OPTARG is unset' || echo "OPTARG=${OPTARG}"
declare -p OPTARG 2>&1 | grep -oe 'OPTARG.*'
done

shift $(( OPTIND - 1 ))
Expand Down
2 changes: 1 addition & 1 deletion test/bin/getopts-verbose
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ while getopts "to:v:" OPTKEY; do
;;
esac
printf ' -- '
[[ -z "${OPTARG+SET}" ]] && echo 'OPTARG is unset' || echo "OPTARG=${OPTARG}"
declare -p OPTARG 2>&1 | grep -oe 'OPTARG.*'
done

shift $(( OPTIND - 1 ))
Expand Down
2 changes: 1 addition & 1 deletion test/bin/getopts_long-github_26-silent
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ while getopts_long ':to:v: toggle option: variable: -toggle -option:' OPTKEY; do
;;
esac
printf ' -- '
[[ -z "${OPTARG+SET}" ]] && echo 'OPTARG is unset' || echo "OPTARG=${OPTARG}"
declare -p OPTARG 2>&1 | grep -oe 'OPTARG.*'
done

shift $(( OPTIND - 1 ))
Expand Down
2 changes: 1 addition & 1 deletion test/bin/getopts_long-github_26-verbose
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ while getopts_long 'to:v: toggle option: variable: -toggle -option:' OPTKEY; do
;;
esac
printf ' -- '
[[ -z "${OPTARG+SET}" ]] && echo 'OPTARG is unset' || echo "OPTARG=${OPTARG}"
declare -p OPTARG 2>&1 | grep -oe 'OPTARG.*'
done

shift $(( OPTIND - 1 ))
Expand Down
2 changes: 1 addition & 1 deletion test/bin/getopts_long-longspec_with_dash-silent
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ while getopts_long ':to:v: - toggle option: variable:' OPTKEY; do
;;
esac
printf ' -- '
[[ -z "${OPTARG+SET}" ]] && echo 'OPTARG is unset' || echo "OPTARG=${OPTARG}"
declare -p OPTARG 2>&1 | grep -oe 'OPTARG.*'
done

shift $(( OPTIND - 1 ))
Expand Down
2 changes: 1 addition & 1 deletion test/bin/getopts_long-longspec_with_dash-verbose
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ while getopts_long 'to:v: - toggle option: variable:' OPTKEY; do
;;
esac
printf ' -- '
[[ -z "${OPTARG+SET}" ]] && echo 'OPTARG is unset' || echo "OPTARG=${OPTARG}"
declare -p OPTARG 2>&1 | grep -oe 'OPTARG.*'
done

shift $(( OPTIND - 1 ))
Expand Down
2 changes: 1 addition & 1 deletion test/bin/getopts_long-longspec_with_dash_colon-silent
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ while getopts_long ':to:v: -: toggle option: variable:' OPTKEY; do
;;
esac
printf ' -- '
[[ -z "${OPTARG+SET}" ]] && echo 'OPTARG is unset' || echo "OPTARG=${OPTARG}"
declare -p OPTARG 2>&1 | grep -oe 'OPTARG.*'
done

shift $(( OPTIND - 1 ))
Expand Down
2 changes: 1 addition & 1 deletion test/bin/getopts_long-longspec_with_dash_colon-verbose
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ while getopts_long 'to:v: -: toggle option: variable:' OPTKEY; do
;;
esac
printf ' -- '
[[ -z "${OPTARG+SET}" ]] && echo 'OPTARG is unset' || echo "OPTARG=${OPTARG}"
declare -p OPTARG 2>&1 | grep -oe 'OPTARG.*'
done

shift $(( OPTIND - 1 ))
Expand Down
2 changes: 1 addition & 1 deletion test/bin/getopts_long-no_shortspec-silent
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ while getopts_long ': toggle option: variable:' OPTKEY; do
;;
esac
printf ' -- '
[[ -z "${OPTARG+SET}" ]] && echo 'OPTARG is unset' || echo "OPTARG=${OPTARG}"
declare -p OPTARG 2>&1 | grep -oe 'OPTARG.*'
done

shift $(( OPTIND - 1 ))
Expand Down
2 changes: 1 addition & 1 deletion test/bin/getopts_long-no_shortspec-verbose
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ while getopts_long ' toggle option: variable:' OPTKEY; do
;;
esac
printf ' -- '
[[ -z "${OPTARG+SET}" ]] && echo 'OPTARG is unset' || echo "OPTARG=${OPTARG}"
declare -p OPTARG 2>&1 | grep -oe 'OPTARG.*'
done

shift $(( OPTIND - 1 ))
Expand Down
Loading
Loading