[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
<<IFS=: foo=a:b:; cmd $foo>> documented
From: |
Stephane Chazelas |
Subject: |
<<IFS=: foo=a:b:; cmd $foo>> documented |
Date: |
Tue, 12 Oct 2004 10:10:15 +0100 |
User-agent: |
Mutt/1.5.6i |
Hi,
That piece of code:
IFS=:
set -f
foo=a:b:
printf '<%s>\n' $foo
gives different results depending on the shell.
With pdksh, zsh, it gives:
<a>
<b>
<>
With bash, ksh, dash:
<a>
<b>
Also with the Bourne shell, but so does "a::b".
One would expect zsh's behavior if IFS is supposed to be a field
_separator_. On the other end, with zsh's behavior, there's no
way to distinguish between an empty list and a list with one
empty element.
But, with bash behavior, you can't loop through $PATH
components, as in $PATH, "/bin:" means ("/bin", ""), i.e. "/bin"
and the current directory.
The problem is I can't see that behavior documented clearly in
info -f bash -n 'Word Splitting'
regards,
Stephane
- <<IFS=: foo=a:b:; cmd $foo>> documented,
Stephane Chazelas <=