File tree Expand file tree Collapse file tree 3 files changed +28
-6
lines changed Expand file tree Collapse file tree 3 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,8 @@ Any uppercase BUG_* names are modernish shell bug IDs.
180
180
etc. to lose their effect after being unset in a subshell. For example:
181
181
(unset PATH; PATH=/dev/null; ls); : wrongly ran 'ls'
182
182
(unset LC_ALL; LC_ALL=badlocale); : failed to print a diagnostic
183
+ This also fixes BUG_KUNSETIFS: unsetting IFS in a subshell failed if IFS
184
+ was set to the empty value in the parent shell.
183
185
184
186
- Fix crashes on some systems, including at least a crash in 'print -v' on
185
187
macOS, by eliminating an invalid/undefined use of memccpy() on overlapping
Original file line number Diff line number Diff line change @@ -71,12 +71,6 @@ https://github.com/modernish/modernish/tree/0.16/lib/modernish/cap/
71
71
are erroneously interpreted as wildcards when quoted "$*" is used as the
72
72
glob pattern.
73
73
74
- - BUG_KUNSETIFS: ksh93: Can't unset IFS under very specific circumstances.
75
- unset -v IFS is a known POSIX shell idiom to activate default field
76
- splitting. With this bug, the unset builtin silently fails to unset IFS
77
- (i.e. fails to activate field splitting) if we're executing an eval or a
78
- trap and a number of specific conditions are met.
79
-
80
74
- BUG_LOOPRET2: If a 'return' command is given without a status argument
81
75
within the set of conditional commands in a 'while' or 'until' loop (i.e.,
82
76
between 'while'/'until' and 'do'), the exit status passed down from the
Original file line number Diff line number Diff line change 268
268
for i in : % + / 3b ' ** ' ' *** ' ' @@' ' {' ' [' ' }' !! ' * a' ' $foo '
269
269
do (eval : \${"$i"} 2> /dev/null) && err_exit "\${$i} not an syntax error"
270
270
done
271
+
272
+ # ___ begin: IFS tests ___
273
+
271
274
unset IFS
272
275
( IFS=' ' ; read -r a b c <<-!
273
276
x y z
418
421
;;
419
422
esac
420
423
done
424
+
425
+ # BUG_KUNSETIFS: Unsetting IFS fails to activate default default field splitting if two conditions are met:
426
+ IFS=' ' # condition 1: no split in main shell
427
+ : ${foo-} # at least one expansion is also needed to trigger this
428
+ ( # condition 2: subshell (non-forked)
429
+ unset IFS
430
+ v="one two three"
431
+ set -- $v
432
+ let "$# == 3" # without bug, should be 3
433
+ ) || err_exit ' IFS fails to be unset in subshell (BUG_KUNSETIFS)'
434
+
435
+ # Test known BUG_KUNSETIFS workaround (assign to IFS before unset)
436
+ IFS= v=
437
+ : ${v:=a$' \n ' bc$' \t ' def\ gh}
438
+ case $(unset IFS; set -- $v; print $#) in
439
+ 4 | 1) # test if the workaround works whether we' ve got the bug or not
440
+ v= $( IFS=foobar; unset IFS; set -- $v ; print $# )
441
+ [[ $v == 4 ]] || err_exit " BUG_KUNSETIFS workaround fails (expected 4, got $v )" ;;
442
+ * ) err_exit ' BUG_KUNSETIFS detection failed'
443
+ esac
444
+
445
+ # ^^^ end: IFS tests ^^^
446
+ # restore default split:
421
447
unset IFS
422
448
423
449
if [[ $( (print ${12345:? } ) 2>&1 ) != * 12345* ]]
You can’t perform that action at this time.
0 commit comments