mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Modernish is no longer detecting BUG_KUNSETIFS, as I've just discovered. Always nice when bugs spontaneously vanish... A 'git reset HEAD~1'/recompile/retest loop reveals this bug was fixed by6f0e008c
, as later modified by7b994b6a
. So, let's make sure it stays fixed. src/cmd/ksh93/tests/variables.sh: - Add a couple of regression tests for BUG_KUNSETIFS presence, detection and known workaround, based on the same in modernish. Ref.:3ddcbd13/lib/modernish/cap/BUG_KUNSETIFS.t
3ddcbd13/lib/modernish/tst/isset.t (L204-L222)
This commit is contained in:
parent
43c09c2d6f
commit
2315f6687a
3 changed files with 28 additions and 6 deletions
|
@ -268,6 +268,9 @@ fi
|
|||
for i in : % + / 3b '**' '***' '@@' '{' '[' '}' !! '*a' '$foo'
|
||||
do (eval : \${"$i"} 2> /dev/null) && err_exit "\${$i} not an syntax error"
|
||||
done
|
||||
|
||||
# ___ begin: IFS tests ___
|
||||
|
||||
unset IFS
|
||||
( IFS=' ' ; read -r a b c <<-!
|
||||
x y z
|
||||
|
@ -418,6 +421,29 @@ do
|
|||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# BUG_KUNSETIFS: Unsetting IFS fails to activate default default field splitting if two conditions are met:
|
||||
IFS='' # condition 1: no split in main shell
|
||||
: ${foo-} # at least one expansion is also needed to trigger this
|
||||
( # condition 2: subshell (non-forked)
|
||||
unset IFS
|
||||
v="one two three"
|
||||
set -- $v
|
||||
let "$# == 3" # without bug, should be 3
|
||||
) || err_exit 'IFS fails to be unset in subshell (BUG_KUNSETIFS)'
|
||||
|
||||
# Test known BUG_KUNSETIFS workaround (assign to IFS before unset)
|
||||
IFS= v=
|
||||
: ${v:=a$'\n'bc$'\t'def\ gh}
|
||||
case $(unset IFS; set -- $v; print $#) in
|
||||
4 | 1) # test if the workaround works whether we've got the bug or not
|
||||
v=$(IFS=foobar; unset IFS; set -- $v; print $#)
|
||||
[[ $v == 4 ]] || err_exit "BUG_KUNSETIFS workaround fails (expected 4, got $v)" ;;
|
||||
*) err_exit 'BUG_KUNSETIFS detection failed'
|
||||
esac
|
||||
|
||||
# ^^^ end: IFS tests ^^^
|
||||
# restore default split:
|
||||
unset IFS
|
||||
|
||||
if [[ $( (print ${12345:?}) 2>&1) != *12345* ]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue