[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Anomalies with ${*}
From: |
Chet Ramey |
Subject: |
Re: [Help-bash] Anomalies with ${*} |
Date: |
Tue, 27 Mar 2012 12:38:56 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 |
On 3/27/12 12:13 AM, Bill Gradwohl wrote:
It doesn't look like anyone answered this part of the question.
> It works when IFS='' precedes read on the same line, so why not before set?
You have to look at how commands are processed, and how `read' and `set'
use $IFS. This reference explains simple command processing:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01
Assignment statements preceding the command are saved until after word
expansion. That means that set and read both receive the arguments as
split using whatever value IFS had before the command. The difference
is that read actually uses $IFS to process the words it reads, while set
does not.
The other thing to take into account is that Posix specifies that
assignment statements preceding special builtins like `set' stay in
effect after the special builtin completes. Bash doesn't do this
by default, but does when Posix mode is in effect. You'll get different
results if you run your original code with `bash' and `sh'.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/
- [Help-bash] Anomalies with ${*}, Bill Gradwohl, 2012/03/27
- Re: [Help-bash] Anomalies with ${*}, Greg Wooledge, 2012/03/27
- Re: [Help-bash] Anomalies with ${*}, Bill Gradwohl, 2012/03/27
- Re: [Help-bash] Anomalies with ${*}, Greg Wooledge, 2012/03/27
- Re: [Help-bash] Anomalies with ${*}, Bill Gradwohl, 2012/03/27
- Re: [Help-bash] Anomalies with ${*}, Eric Blake, 2012/03/27
- Re: [Help-bash] Anomalies with ${*}, Bill Gradwohl, 2012/03/27
Re: [Help-bash] Anomalies with ${*},
Chet Ramey <=