bug-bash
[Top][All Lists]
Advanced

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

Re: The IFS variable - a confusing issue. [+POSIX conformance pb]


From: Stephane Chazelas
Subject: Re: The IFS variable - a confusing issue. [+POSIX conformance pb]
Date: Mon, 18 Oct 2004 09:43:37 +0100
User-agent: Mutt/1.5.6i

On Sat, Oct 16, 2004 at 03:42:46PM +0200, Enrique Perez-Terron wrote:
[...]
> You could try the following:
> 
>          2 IFS=: eval "list=(\$PATH)"
>          3 for d in "${list[@]}"; do
> 
> (Sorry for the massive punctuation needed.)
> 
> It has the advantage of not changing IFS other than for the eval
> command.  

Well, you shouldn't rely on that, as in POSIX mode and in other
/POSIX/ shells such as ksh or zsh in sh mode or dash (and also
the Bourne shell), it is not true:

http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_14

    2. Variable assignments specified with special built-in
    utilities remain in effect after the built-in completes;
    this shall not be the case with a regular built-in or other
    utility.
    [eval is "special builtin"].

You should be able to do:

IFS=: command eval 'list=($PATH)'

as "command" is not a special builtin. However, it works with
ksh or zsh but doesn't seem to work with bash --posix (3.0.13,
bug?).

$ /usr/local/bin/bash --posix -c '
> IFS=: command eval "list=(\$PATH)"; echo "$IFS"'
:
$ 

-- 
Stephane




reply via email to

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