bug-bash
[Top][All Lists]
Advanced

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

Re: Question on differences on quoted $* (Was: Re: Question on $@ vs $@$


From: Robert Elz
Subject: Re: Question on differences on quoted $* (Was: Re: Question on $@ vs $@$@)
Date: Sat, 24 Aug 2024 11:52:52 +0700

    Date:        Sat, 24 Aug 2024 02:33:26 +0200
    From:        Emanuele Torre <torreemanuele6@gmail.com>
    Message-ID:  <ZskqVqdZSXMHns1k@ntoo>

  | No. It is working correctly.

It is indeed.

  | This $1 is unquoted, it will be split. You need to use "$1" if you don't
  | want it to split.

Alternatively, make a() be

        a()
        {
                local IFS=
                echo $#,1=$1,2=$2,"$*",$*,
        }

then you'll get to see what the actual args are, as no splitting
will happen.  Of course, the expansion of "$*" will be different
in this case (but the the unquoted version only by not having
word splitting performed on the fields it produces).

You could also see what happened in the original case if you ran
the test with -x set (this segment from the final input line):

+ IFS=:
+ echo a:b:ca b c a b c
a:b:ca b c a b c
+ a a:b:ca b c a b c
+ echo 6,1=a b ca,2=b,a:b:ca:b:c:a:b:c,a b ca b c a b c,
6,1=a b ca,2=b,a:b:ca:b:c:a:b:c,a b ca b c a b c,
+ unset IFS

You can see there that the args passed to 'a' and the args passed
to the first "echo" (outside 'a') are identical.

kre




reply via email to

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