[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: possible bug with $@ and and non-standard IFS
From: |
JR Rothschild |
Subject: |
Re: possible bug with $@ and and non-standard IFS |
Date: |
Tue, 4 Aug 2009 12:10:56 -0400 |
Apparently, I have run into an area of some controversy (or at least
some disagreement)
On my Solaris 10 box,
ksh thinks that the expected output should be smith::0.0
sh -> smith:0.0
(an old version of bash) -> smith: 0.0
dtksh-> smith: 0.0
I don't think this will get solved anytime soon. :) Thanks for your
help. We have a workaround.
JR
On Tue, Aug 4, 2009 at 10:01 AM, Chet Ramey<chet.ramey@case.edu> wrote:
> 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/
>