bug-bash
[Top][All Lists]
Advanced

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

Re: Question on $@ vs $@$@


From: Steffen Nurpmeso
Subject: Re: Question on $@ vs $@$@
Date: Fri, 23 Aug 2024 01:28:49 +0200
User-agent: s-nail v14.9.25-599-g5c75a327b2

Hello.

Sorry for being here again, rather bash unrelated mostly..

Steffen Nurpmeso wrote in
 <20240816215210.PMy3rwiy@steffen%sdaoden.eu>:
 |Steffen Nurpmeso wrote in
 | <20240816212216.accse4FG@steffen%sdaoden.eu>:
 ||Robert Elz wrote in
 || <16443.1723841436@jacaranda.noi.kre.to>:
 |||    Date:        Thu, 15 Aug 2024 23:33:42 +0200
 |||    From:        Steffen Nurpmeso <steffen@sdaoden.eu>
 |||    Message-ID:  <20240815213342.t6-hdjZT@steffen%sdaoden.eu>
 |||
 |||| I have extended the test a bit, and i also see word split
 |||| differences.
 |||
 |||There are so many problems with this test, that I'm not sure
 |||it is worth bothering looking to see what happens, or why there
 |||are differences.
 ||
 ||Might very well be it is true what you say for IFS, i should place
 ||a semicolon after its' assignment.

In the meantime it turns out dash has another problem with
IFS="\011" which i falsely tried because some shells do not
support IFS=$'\t' yet.  (Ie, that is de-facto [\01] it seems.)
But that aside.

I have myself a failure and i do not understand what i do wrong,
maybe someone could give me a hint on that, that would be nice.
If i have

  a() { echo $#,1=$1,2=$2,"$*",$*,; }
  set -- a b c
  echo 2
  IFS=:; echo "$*"$*; a $* "$*";

then bash gives me

  2
  a:b:ca b c
  4,1=a,2=b,a:b:c:a:b:c,a b c a b c,

whereas my little mailer says

  2
  a:b:ca b c
  2,1=a b c,2=a:b:c,a b c:a:b:c,a b c a b c,

What i do not understand is the difference in between the $*
expansion in the call to "a".
Why does bash (aka sh(1)) word splits

  IFS=:; echo "$*"$*; a $* "$*";
                        ^
                        this

unquoted $* at SPACE into three different tokens?
And space is not in $IFS when the call to "a" is prepared.
Ie if "$*" is expanded to "a b c" (which it likely is), and then
"a b c" is word-splitted via $IFS, then, since $IFS is only colon,
"a b c" cannot be splitted at all?
All shells i have tried do it like that, but i cannot find any
words in POSIX 2.6.5 word splitting etc that make me wrap my head
around this behaviour.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)



reply via email to

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