[Top][All Lists]

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

Re: IFS=':' set -- aa:bb:cc:dd # Fails to set "$@"

From: Chris F.A. Johnson
Subject: Re: IFS=':' set -- aa:bb:cc:dd # Fails to set "$@"
Date: Wed, 1 Dec 2010 13:55:07 -0500 (EST)
User-agent: Alpine 2.00 (LMD 1167 2008-08-23)

On Wed, 1 Dec 2010, address@hidden wrote:

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' 
-DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib  -D_GNU_SOURCE 
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic 
uname output: Linux saturn.syslang.net #1 SMP 
Thu Dec 10 10:48:30 EST 2009 i686 athlon i386 GNU/Linux
Machine Type: i386-redhat-linux-gnu

Bash Version: 3.2
Patch Level: 39
Release Status: release

        It may be me, but I tried something that I thought should work, but it 
does not. I want to use the set command to parse data and I want the IFS 
variable to be in force during the set command. This does not work. So far, 
every other use of
var=val cmd
seems to work fine. Only this one plays funny.

        IFS=':' set -- aa:bb:cc:dd
        echo $1
        # After this runs, $1 is aa:bb:cc:dd instead of aa
        Instead, I have to say something like:
        set -- aa:bb:cc:dd

        BTW, the same behavior happens in bash4.

        Offered in the constructive spirit to see if this needs to be fixed or 
if this is a deliberate or known behavior.

   That is the way it should behave.

   The line is parsed before IFS is set.

   Chris F.A. Johnson, <http://cfajohnson.com>
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

reply via email to

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