On 03/12/2015 22:17, Stephane Chazelas wrote:
2015-12-03 22:02:14 +0100, Harald van Dijk:
[....]
$ for shell in bash mksh posh zsh; do printf %s: "$shell"; $shell
-c 'IFS=,; echo a, | { read v; echo "<$v>"; }'; done
bash:<a>
mksh:<a>
posh:<a,>
zsh:<a,>
As far as I can tell, the posh/zsh behaviour is the correct
behaviour, but I'm not convinced yet my interpretation is correct.
[...]
No, that would be the same as for:
v=a:b:
IFS=:
set -f
set -- $v
It's meant to split into "a" and "b", not "a", "b" and "". As
":" is meant to be treated as a *delimiter* or *terminator*.
That has been discussed a few times on the austin group mailing
list.
zsh and pdksh (and other descendants of the Forsyth shell) treat it as
separator (and are not compliant), mksh (derived from pdksh)
changed it recently. posh (also based on pdksh) still hasn't changed it.
zsh indeed expands this into "a", "b" and "". The same version of posh
that gives <a,> for my test gives just "a" and "b" for yours though.
I do see your point. Thanks for the clear example, I think I agree with
you, the description of field splitting mentions that delimiters are
used as terminators:
"The shell shall treat each character of the IFS as a delimiter and
use the delimiters as field terminators to [...]"
It should not be much of a problem to extend the patch I posted to cover
the rules as you describe them, I will make an attempt at this later.
Cheers,
Harald van Dijk
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html