mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
set --default: properly restore ksh IFS behaviour (re: 9e2a8c69)
Reproducer: $ (IFS=$'\t\t'; val=$'\tone\t\ttwo\t'; set --posix; \ set -- $val; echo $#; set --noposix; set -- $val; echo $#) 2 4 <== OK $ (IFS=$'\t\t'; val=$'\tone\t\ttwo\t'; set --posix; \ set -- $val; echo $#; set --default; set -- $val; echo $#) 2 2 <== bug The output of the seconnd command line should be like the first. When POSIX mode is turned off using 'set --noposix' (or 'set +o posix'), sh.ifstable is invalidated as it needs to be repopulated on the next field split to restore ksh-specific special handling of a repeated $IFS whitespace character as non-whitespace. However, when 'set --default' is used, this does not happen, which is a bug. src/cmd/ksh93/sh/args.c: sh_argopts(): - While processing --default, when turning off SH_POSIX, call sh_invalidate_ifs() to invalidate sh.ifstable.
This commit is contained in:
parent
83baa27ef9
commit
8f14514661
4 changed files with 16 additions and 1 deletions
|
|
@ -113,6 +113,9 @@ got=$(set --noposix; set $val; echo "$#")
|
|||
exp=5
|
||||
[[ $got == "$exp" ]] || err_exit "repeated IFS whitespace char (noposix): incorrect number of fields" \
|
||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||
got=$(set --default; set $val; echo "$#")
|
||||
[[ $got == "$exp" ]] || err_exit "repeated IFS whitespace char (default): incorrect number of fields" \
|
||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||
IFS=$' \t\n' # default
|
||||
|
||||
# causes file descriptors > 2 to be left open when invoking another program;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue