mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
posix mode: disable effect of repeating whitespace char in $IFS
ksh has a little-known field splitting feature that conflicts with POSIX: if a single-byte whitespace character (cf. isspace(3)) is repated in $IFS, then field splitting is done as if that character wasn't a whitespace character. An exmaple with the tab character: $ (IFS=$'\t'; val=$'\tone\t\ttwo\t'; set -- $val; echo $#) 2 $ (IFS=$'\t\t'; val=$'\tone\t\ttwo\t'; set -- $val; echo $#) 4 The latter being the same as, for example $ (IFS=':'; val='1️⃣2️⃣'; set -- $val; echo $#) 4 However, this is incompatible with the POSIX spec and with every other shell except zsh, in which repeating a character in IFS does not have any effect. So the POSIX mode must disable this. src/cmd/ksh93/include/defs.h, src/cmd/ksh93/sh/init.c: - Add sh_invalidate_ifs() function that invalidates the IFS state table by setting the ifsnp discipline struct member to NULL, which will cause the next get_ifs() call to regenerate it. - get_ifs(): Treat a repeated char as S_DELIM even if whitespace, unless --posix is on. src/cmd/ksh93/sh/args.c: - sh_argopts(): Call sh_invalidate_ifs() when enabling or disabling the POSIX option. This is needed to make the change in field splitting behaviour take immediate effect instead of taking effect at the next assignment to IFS.
This commit is contained in:
parent
fae1932e62
commit
9e2a8c6925
5 changed files with 33 additions and 5 deletions
3
NEWS
3
NEWS
|
@ -7,6 +7,9 @@ Any uppercase BUG_* names are modernish shell bug IDs.
|
|||
|
||||
- The 'enum' command can now create more than one type per invocation.
|
||||
|
||||
- The POSIX compatibility mode has been amended to disable the special handling
|
||||
of a repeated $IFS whitespace character as non-whitespace.
|
||||
|
||||
2022-02-23:
|
||||
|
||||
- When reading input from the keyboard, ksh now turns off nonblocking I/O
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue