On Sat, Aug 24, 2024 at 02:15:48AM +0200, Steffen Nurpmeso wrote: > Sorry but i really have to come again, i do not understand what is > going on, and *i* think shell is at fault.
No. It is working correctly. > > This: > > a() { > echo $#,1=$1,2=$2,"$*",$*, This $1 is unquoted, it will be split. You need to use "$1" if you don't want it to split. > } > echo "$*"$* $*; a "$*"$* $* > echo __ > IFS=:;echo "$*"$* $*; a "$*"$* $*;unset IFS > echo == > set -- a b c > echo "$*"$* $*; a "$*"$* $* > echo 0 > IFS=:; echo "$*"$* $*; a "$*"$* $*;unset IFS > > gives this output: > > 1,1=,2=,,, > __ > > 1,1=,2=,,, > == > 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, > 0 > 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, > > Compared to the output of my MUA this is > > @@ -8,4 +8,4 @@ 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, > 0 > 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, > +6,1=a:b:ca,2=b,a:b:ca:b:c:a:b:c,a b ca b c a b c, > > Why does bash, when preparing the first argument to the function > a(), ie, when word-splitting "$*", not generate "a:b:c" as it very > well does when it creates the output for echo(1)? > Where is the difference in between the '"$*"$* $*' of the one > argument, and the '"$*"$* $*' of the other? Even though you are passing "a:b:ca" as $1, you are running echo $1 to print it while IFS is still set to ":" so $1 will be split to "a" "b" "ca". > In both cases $* is in between quotes and needs to be expanded > with the first byte (character) of $IFS as a separator, this is > what i do not understand. Is this a bug in bash? What rule am > i missing if not? Simple example. $ IFS=: $ a () { echo $1 ;} $ echo 1:2 1:2 $ a 1:2 1 2 > > Thank you very much. > > > --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) > o/ emanuele6