help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Simple echo is printing the wrong value


From: Greg Wooledge
Subject: Re: [Help-bash] Simple echo is printing the wrong value
Date: Thu, 5 Apr 2012 08:18:06 -0400
User-agent: Mutt/1.4.2.3i

On Wed, Apr 04, 2012 at 09:24:44PM -0600, Bill Gradwohl wrote:
> IFS= read                works

This sets the IFS variable to an empty string for the duration of the
read command.

> set -- '' '' ''
> IFS= echo "${*}"         doesn't

You mean it doesn't do what you expected, whatever that was.

> Yes - I know its a parser issue, but its still unexpected.
> 
> I'm trying to figure it out.

It expands the positional parameters to a single string using the current
value of IFS (by default, $' \t\n'), and then passes that string to echo
as a single argument.  The IFS variable is also set to an empty string
for the duration of the echo command, but since echo doesn't *use* IFS
for anything, that part has no effect.

It's all about the order in which the various steps are performed.  Or
in the case of "case", the steps which are omitted.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]