mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 11:42:21 +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
6
NEWS
6
NEWS
|
@ -3,6 +3,12 @@ For full details, see the git log at: https://github.com/ksh93/ksh/tree/1.0
|
||||||
|
|
||||||
Any uppercase BUG_* names are modernish shell bug IDs.
|
Any uppercase BUG_* names are modernish shell bug IDs.
|
||||||
|
|
||||||
|
2022-05-27:
|
||||||
|
|
||||||
|
- Fixed a bug introduced on 2022-03-05 where 'set --default', while turning
|
||||||
|
off the --posix option, did not re-enable the special handling of a repeated
|
||||||
|
$IFS whitespace character as non-whitespace.
|
||||||
|
|
||||||
2022-05-25:
|
2022-05-25:
|
||||||
|
|
||||||
- Fixed a bug introduced on 2021-02-20 that caused incorrect output for
|
- Fixed a bug introduced on 2021-02-20 that caused incorrect output for
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
|
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
|
||||||
#define SH_RELEASE_SVER "1.0.0-beta.2" /* semantic version number: https://semver.org */
|
#define SH_RELEASE_SVER "1.0.0-beta.2" /* semantic version number: https://semver.org */
|
||||||
#define SH_RELEASE_DATE "2022-05-25" /* must be in this format for $((.sh.version)) */
|
#define SH_RELEASE_DATE "2022-05-27" /* must be in this format for $((.sh.version)) */
|
||||||
#define SH_RELEASE_CPYR "(c) 2020-2022 Contributors to ksh " SH_RELEASE_FORK
|
#define SH_RELEASE_CPYR "(c) 2020-2022 Contributors to ksh " SH_RELEASE_FORK
|
||||||
|
|
||||||
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
|
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
|
||||||
|
|
|
@ -170,8 +170,14 @@ int sh_argopts(int argc,register char *argv[])
|
||||||
{
|
{
|
||||||
register const Shtable_t *tp;
|
register const Shtable_t *tp;
|
||||||
for(tp=shtab_options; o = tp->sh_number; tp++)
|
for(tp=shtab_options; o = tp->sh_number; tp++)
|
||||||
|
{
|
||||||
if(!(o&SH_COMMANDLINE) && (o&=0xff)!=SH_RESTRICTED && is_option(&newflags,o))
|
if(!(o&SH_COMMANDLINE) && (o&=0xff)!=SH_RESTRICTED && is_option(&newflags,o))
|
||||||
|
{
|
||||||
off_option(&newflags,o);
|
off_option(&newflags,o);
|
||||||
|
if(o==SH_POSIX)
|
||||||
|
sh_invalidate_ifs();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
defaultflag++;
|
defaultflag++;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -113,6 +113,9 @@ got=$(set --noposix; set $val; echo "$#")
|
||||||
exp=5
|
exp=5
|
||||||
[[ $got == "$exp" ]] || err_exit "repeated IFS whitespace char (noposix): incorrect number of fields" \
|
[[ $got == "$exp" ]] || err_exit "repeated IFS whitespace char (noposix): incorrect number of fields" \
|
||||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
"(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
|
IFS=$' \t\n' # default
|
||||||
|
|
||||||
# causes file descriptors > 2 to be left open when invoking another program;
|
# causes file descriptors > 2 to be left open when invoking another program;
|
||||||
|
|
Loading…
Reference in a new issue