[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: possible bug with $@ and and non-standard IFS
From: |
Chet Ramey |
Subject: |
Re: possible bug with $@ and and non-standard IFS |
Date: |
Tue, 04 Aug 2009 10:01:03 -0400 |
User-agent: |
Thunderbird 2.0.0.22 (Macintosh/20090605) |
JR Rothschild wrote:
> Hi,
> In either version 3.1.17 (SUSE 10) or 3.2.25 (RHEL 5.3), with $DISPLAY
> set to :0.0
> the following script gives unexpected results.(It works with version
> 3.0.15 - RHEL4.6) The echo should print out
>
> smith:0.0
It shouldn't display that; there are different bugs in 3.0 and 3.1/3.2.
> instead of
>
> smith 0.0
That's not right, either.
> #!!/bin/bash
> dh=smith
> oldIFS=$IFS
> IFS=:
> set $DISPLAY
> nd="${dh}:$@"
> IFS=$oldIFS
>
> echo $nd
The correct output is "smith: 0.0". The `smith' from $dh, the literal
colon, the space from the spaces separating the "$@" (splitting on `:'
results in $1 being a null field), then the 0.0 ($2).
If you use nd="${dh}$*" before resetting IFS, you'll get the output you
in bash-3.0 through bash-4.0.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/