mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix compile/regress fails on compiling without SHOPT_* options
Many compile-time options were broken so that they could not be
turned off without causing compile errors and/or regression test
failures. This commit now allows the following to be disabled:
SHOPT_2DMATCH # two dimensional ${.sh.match} for ${var//pat/str}
SHOPT_BGX # one SIGCHLD trap per completed job
SHOPT_BRACEPAT # C-shell {...,...} expansions (, required)
SHOPT_ESH # emacs/gmacs edit mode
SHOPT_HISTEXPAND # csh-style history file expansions
SHOPT_MULTIBYTE # multibyte character handling
SHOPT_NAMESPACE # allow namespaces
SHOPT_STATS # add .sh.stats variable
SHOPT_VSH # vi edit mode
The following still break ksh when disabled:
SHOPT_FIXEDARRAY # fixed dimension indexed array
SHOPT_RAWONLY # make viraw the only vi mode
SHOPT_TYPEDEF # enable typeset type definitions
Compiling without SHOPT_RAWONLY just gives four regression test
failures in pty.sh, but turning off SHOPT_FIXEDARRAY and
SHOPT_TYPEDEF causes compilation to fail. I've managed to tweak the
code to make it compile without those two options, but then dozens
of regression test failures occur, often in things nothing directly
to do with those options. It looks like the separation between the
code for these options and the rest was never properly maintained.
Making it possible to disable SHOPT_FIXEDARRAY and SHOPT_TYPEDEF
may involve major refactoring and testing and may not be worth it.
This commit has far too many tweaks to list. Notables fixes are:
src/cmd/ksh93/data/builtins.c,
src/cmd/ksh93/data/options.c:
- Do not compile in the shell options and documentation for
disabled features (braceexpand, emacs/gmacs, vi/viraw), so the
shell is not left with no-op options and inaccurate self-doc.
src/cmd/ksh93/data/lexstates.c:
- Comment the state tables to associte them with their IDs.
- In the ST_MACRO table (sh_lexstate9[]), do not make the S_BRACE
state for position 123 (ASCII for '{') conditional upon
SHOPT_BRACEPAT (brace expansion), otherwise disabling this causes
glob patterns of the form {3}(x) (matching 3 x'es) to stop
working as well -- and that is ksh globbing, not brace expansion.
src/cmd/ksh93/edit/edit.c: ed_read():
- Fixed a bug: SIGWINCH was not handled by the gmacs edit mode.
src/cmd/ksh93/sh/name.c: nv_putval():
- The -L/-R left/right adjustment options to typeset do not count
zero-width characters. This is the behaviour with SHOPT_MULTIBYTE
enabled, regardless of locale. Of course, what a zero-width
character is depends on the locale, but control characters are
always considered zero-width. So, to avoid a regression, add some
fallback code for non-SHOPT_MULTIBYTE builds that skips ASCII
control characters (as per iscntrl(3)) so they are still
considered to have zero width.
src/cmd/ksh93/tests/shtests:
- Export the SHOPT_* macros from SHOPT.sh to the tests as
environment variables, so the tests can check for them and decide
whether or how to run tests based on the compile-time options
that the tested binary was presumably compiled with.
- Do not run the C.UTF-8 tests if SHOPT_MULTIBYTE is not enabled.
src/cmd/ksh93/tests/*.sh:
- Add a bunch of checks for SHOPT_* env vars. Since most should
have a value 0 (off) or 1 (on), the form ((SHOPT_FOO)) is a
convenient way to use them as arithmetic booleans.
.github/workflows/ci.yml:
- Make GitHub do more testing: run two locale tests (Dutch and
Japanese UTF-8 locales), then disable all the SHOPTs that we can
currently disable, recompile ksh, and run the tests again.
This commit is contained in:
parent
a9d77bba40
commit
2182ecfa08
40 changed files with 413 additions and 157 deletions
|
|
@ -202,20 +202,21 @@ rm .profile
|
|||
|
||||
# { exec interactive login_shell restricted xtrace } in the following test
|
||||
|
||||
for opt in \
|
||||
set -- \
|
||||
allexport all-export all_export \
|
||||
bgnice bg-nice bg_nice \
|
||||
clobber emacs \
|
||||
clobber \
|
||||
errexit err-exit err_exit \
|
||||
glob \
|
||||
globstar glob-star glob_star \
|
||||
gmacs \
|
||||
ignoreeof ignore-eof ignore_eof \
|
||||
keyword log markdirs monitor notify \
|
||||
pipefail pipe-fail pipe_fail \
|
||||
trackall track-all track_all \
|
||||
unset verbose vi \
|
||||
viraw vi-raw vi_raw
|
||||
unset verbose
|
||||
((SHOPT_ESH)) && set -- "$@" emacs gmacs
|
||||
((SHOPT_VSH)) && set -- "$@" vi viraw vi-raw vi_raw
|
||||
for opt
|
||||
do old=$opt
|
||||
if [[ ! -o $opt ]]
|
||||
then old=no$opt
|
||||
|
|
@ -394,15 +395,16 @@ got=$(
|
|||
[[ $got == @((12|21)(12|21)) ]] || err_exit "& job delayed by --pipefail, expected '$exp', got '$got'"
|
||||
$SHELL -c '[[ $- == *c* ]]' || err_exit 'option c not in $-'
|
||||
> $tmp/.profile
|
||||
for i in i l r s D E a b e f h k n t u v x B C G H
|
||||
for i in i l r s D E a b e f h k n t u v x $(let SHOPT_BRACEPAT && echo B) C G $(let SHOPT_HISTEXPAND && echo H)
|
||||
do HOME=$tmp ENV=/./dev/null $SHELL -$i >/dev/null 2>&1 <<- ++EOF++ || err_exit "option $i not in \$-"
|
||||
[[ \$- == *$i* ]] || exit 1
|
||||
++EOF++
|
||||
done
|
||||
letters=ilrabefhknuvxBCGE
|
||||
letters=ilrabefhknuvx$(let SHOPT_BRACEPAT && echo B)CGE
|
||||
integer j=0
|
||||
for i in interactive login restricted allexport notify errexit \
|
||||
noglob trackall keyword noexec nounset verbose xtrace braceexpand \
|
||||
noglob trackall keyword noexec nounset verbose xtrace \
|
||||
$(let SHOPT_BRACEPAT && echo braceexpand) \
|
||||
noclobber globstar rc
|
||||
do HOME=$tmp ENV=/./dev/null $SHELL -o $i >/dev/null 2>&1 <<- ++EOF++ || err_exit "option $i not equivalent to ${letters:j:1}"
|
||||
[[ \$- == *${letters:j:1}* ]] || exit 1
|
||||
|
|
@ -551,6 +553,7 @@ fi
|
|||
|
||||
# ======
|
||||
# Brace expansion could not be turned off in command substitutions (rhbz#1078698)
|
||||
if((SHOPT_BRACEPAT)); then
|
||||
set -B
|
||||
expect='test{1,2}'
|
||||
actual=$(set +B; echo `echo test{1,2}`)
|
||||
|
|
@ -562,6 +565,7 @@ actual=$(set +B; echo $(echo test{1,2}))
|
|||
actual=$(set +B; echo ${ echo test{1,2}; })
|
||||
[[ $actual == "$expect" ]] || err_exit 'Brace expansion not turned off in ${ comsub; }' \
|
||||
"(expected $(printf %q "$expect"), got $(printf %q "$actual"))"
|
||||
fi # SHOPT_BRACEPAT
|
||||
|
||||
# ======
|
||||
# ksh 93u+ did not correctly handle the combination of pipefail and (errexit or the ERR trap).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue