Subject: Re: strange IFS behaviour in /bin/sh ?
To: Geoff Wing <gcw@pobox.com>
From: Eric Haszlakiewicz <erh@jodi.nimenees.com>
List: current-users
Date: 05/11/2004 09:17:46
On Mon, May 10, 2004 at 11:30:04PM +1000, Geoff Wing wrote:
> Eric Haszlakiewicz <erh@nimenees.com> output:
> :# IFS=/
> :# set `echo /dev/wd1e`
> 
> IFS field-splitting is performed on echo argument.  set is
> passed two arguments.
	Actually, according to what Masao mentioned about SUSv3, field splitting
is performed on the _output_ of echo.

On Someday at Sometime, Masao wrote:
>SUSv3 says Field Splitting happens after a) parameter expansion, b)
>command substition, and c) arithmetic expansion.


> :# echo $1
> :dev
> :	However, without the command evaluation it fails the way Darren describes,
> :for any IFS.  e.g.:
> :
> :# IFS=:
> :# set 'root:foo:bar:bax'
> 
> You've enclosed this in single quotes.  It's one argument for set.
	It would be one argument even if I didn't enclose it in quotes,
since it isn't case a b or c.

> :# echo $1
> :root foo bar bax
	What I'm still not clear on is why the : characters dissappear if
field splitting doesn't occur.

> :	Furthermore, setting a variable with that value first, and using it as the
> :arg to set works fine.
> :# var='root:foo:bar:bax'
> :# set $var
> :# echo $1
> :root
> 
> IFS field-splitting is performed on parameter substitution.  This occurs before
> the echo line.
	yes, I see that now.  The set command gets passed 4 parameters.

eric