mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix handling of '--posix' and '--default' (#265)
src/cmd/ksh93/sh/args.c: sh_argopts():
- Remove special-casing for --posix (see also data/builtins.c) and
move the case -5: to the case ':' instead, so this option is
handled like all other long options. This change fixes two bugs:
1. 'set --posix' had no effect on the letoctal or braceexpand
options. Reproducer:
$ set --posix
$ [[ -o braceexpand ]]; echo $?
0
$ [[ -o letoctal ]]; echo $?
1
2. 'ksh --posix' could not run scripts correctly because it
wrongly enabled '-c'. Reproducer:
$ ksh --posix < <(echo 'exit 0')
ksh: -c requires argument
Usage: ksh [--posix] [arg ...]
Help: ksh [ --help | --man ] 2>&1
- Don't allow 'set --default' to unset the restricted option.
src/cmd/ksh93/tests/options.sh:
- Add regression tests for the bugs described above, using -o posix
and --posix.
src/cmd/ksh93/tests/restricted.sh:
- Add a regression test for 'set --default' in rksh.
Co-authored-by: Martijn Dekker <martijn@inlv.org>
This commit is contained in:
parent
cb67a01b45
commit
5461f11968
5 changed files with 25 additions and 12 deletions
|
|
@ -531,8 +531,14 @@ if [[ -o ?posix ]]; then
|
|||
(set -o posix +o letoctal; [[ -o letoctal ]]) && err_exit "failed to stop posix option from turning on letoctal"
|
||||
if((SHOPT_BRACEPAT)); then
|
||||
(set +B; set -o posix -B; [[ -o braceexpand ]]) || err_exit "failed to stop posix option from turning off bracceexpand"
|
||||
(set --posix; [[ -o braceexpand ]]) && err_exit "set --posix fails to disable braceexpand"
|
||||
(set -o posix; [[ -o braceexpand ]]) && err_exit "set -o posix fails to disable braceexpand"
|
||||
fi # SHOPT_BRACEPAT
|
||||
(set --default -o posix; [[ -o letoctal ]]) && err_exit "set --default failed to stop posix option from changing others"
|
||||
(set --posix; [[ -o letoctal ]]) || err_exit "set --posix fails to enable letoctal"
|
||||
(set -o posix; [[ -o letoctal ]]) || err_exit "set -o posix fails to enable letoctal"
|
||||
$SHELL --posix < <(echo 'exit 0') || err_exit "ksh fails to handle --posix during startup"
|
||||
$SHELL -o posix < <(echo 'exit 0') || err_exit "ksh fails to handle -o posix during startup"
|
||||
fi
|
||||
|
||||
# ======
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue