The bug test suite in my modernish shell library exposed a bug in the
current bash development snapshot. As far as I've been able to trace,
the following bug was introduced by bash-snap-20170620 (commit
d7d836dfc55b937f463f601ba5117d6442053089).
I've been able to distil the following test case:
set -o posix
fn() {
IFS= read junk </dev/null
unset -v IFS
[[ -v IFS ]] && echo BUG || echo ok
}
fn
Output: BUG (i.e.: IFS is still set)
Expected output: ok (i.e.: IFS was successfully unset)
"unset -v IFS" (or "unset IFS") is ignored under specific circumstances.
All the four circumstances of the test script seem to need to be present
to trigger the bug:
- the variable needs to be IFS and no other;
- POSIX mode needs to be active;
- it needs to be in a function;
- the 'read' command needs to be executed with an IFS assignment (and no
other command; even "IFS= builtin read junk </dev/null" does not trigger
the bug)
Repeating the "unset -v IFS" command is an effective workaround; it only
seems to fail the once.
- M.