Date:        Sat, 24 Aug 2024 02:33:26 +0200
    From:        Emanuele Torre <torreemanue...@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