mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix how unrecognized options are handled in 'sleep' and 'suspend' (#93)
When a builtin is given an unrecognized option, the usage information for that builtin should be shown as 'Usage: builtin-name options'. The sleep and suspend builtins were an exception to this. 'suspend' would not show usage information and sleep wouldn't exit on error: $ suspend -e /usr/bin/ksh: suspend: -e: unknown option $ time sleep -e 1 sleep: -e: unknown option real 0m1.00s user 0m0.00s sys 0m0.00s src/cmd/ksh93/bltins/sleep.c: - Show usage information and exit when sleep is given an unknown option. This bugfix was backported from ksh2020: https://github.com/att/ast/pull/1024 src/cmd/ksh93/bltins/trap.c: - Use the normal method of parsing options with optget to fix the suspend builtin's test failure. src/cmd/ksh93/tests/builtins.sh: - Add the ksh2020 regression test for getting the usage information of each builtin. Enable all /opt/ast/bin builtins in a subshell since those should be tested as well (aside from getconf and uname because those builtins fallback to the real commands on error).
This commit is contained in:
parent
8b5f11dcd7
commit
1bc2c74c74
4 changed files with 30 additions and 2 deletions
|
@ -885,5 +885,16 @@ fi
|
|||
EOF
|
||||
"$SHELL" -i "$sleepsig" 2> /dev/null || err_exit "'sleep -s' doesn't work with intervals of more than 30 seconds"
|
||||
|
||||
# ==========
|
||||
# Builtins should handle unrecognized options correctly
|
||||
(
|
||||
builtin $(builtin -l | awk -F "/" '/\/opt/ {print $5}') # Load all /opt/ast/bin builtins
|
||||
for name in $(builtin -l | grep -Ev '(echo|/opt|test|true|false|getconf|uname|\[|:)'); do
|
||||
actual="$($name --this-option-does-not-exist 2>&1)"
|
||||
expect="Usage: $name"
|
||||
[[ $actual =~ $expect ]] || err_exit "$name should show usage info on unrecognized options (expected $(printf '%q' "$expect"), got $(printf '%q' "$actual"))"
|
||||
done
|
||||
)
|
||||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue