Dan Douglas dixit:

>For "$@" that sounds about right. I think it would be preferable if x="$@" and 
>x=$@ were the same. If a user wants IFS-delimited they should probably use 

Turns out you’ll get them being the same:

• foo <<<"$@" uses the unquoted $@ inside a quoted string,
  not the quoted $@, interpretation, because here document
  separators (which here strings are handled as) are special

• it’s impossible to treat x="$@" and for x in "$@" differently
  because the expansion subroutine cannot know it’s being used
  to generate a scalar (because the for x in also generates a
  scalar but then applies IFS splitting to it)

Patch attached, it breaks IFS-colon-1 regression test. With this
and my earlier interpretation of the standard and its omissions,
I’ll keep the current behaviour of mksh instead (and in the future,
${foo[@]@Q} will get special treatment instead of just a “DDTT”
when someone uses IFS with it, we’ll see). Note that passing whole
arrays in mksh will, eventually, use JSON natively.

bye,
//mirabilos
-- 
„nein: BerliOS und Sourceforge sind Plattformen für Projekte, github ist
eine Plattform für Einzelkämpfer“
        -- dieses Zitat ist ein Beweis dafür, daß auch ein blindes Huhn
           mal ein Korn findet, bzw. – in diesem Fall – Recht haben kann
Index: check.t
===================================================================
RCS file: /cvs/src/bin/mksh/check.t,v
retrieving revision 1.599
diff -u -p -r1.599 check.t
--- check.t     24 Feb 2013 14:22:41 -0000      1.599
+++ check.t     5 Mar 2013 16:07:35 -0000
@@ -3454,6 +3454,43 @@ expected-stdout:
         <3> <A> <B> <C>
         <4> <A> <B> <C>
 ---
+name: IFS-colon-2
+description:
+       Complex test, IFS=:, with $* and $@ in all variants
+stdin:
+       function expassign {
+               typeset -a a
+               a=("$@")
+               typeset var asn
+       
+               while IFS= read -r asn; do
+                       IFS=: command eval "$asn"
+                       #printf '%-14s... %s\n' "$asn" "$var"
+                       typeset -L14 f=$asn; print -r -- "$f... $var"
+               done <<\EOF
+       var=${a[*]}
+       var="${a[*]}"
+       var=$*
+       var="$*"
+       var=${a[@]}
+       var="${a[@]}"
+       var=$@
+       var="$@"
+       EOF
+       }
+       
+       ${ZSH_VERSION+:} false && emulate ksh
+       expassign one:::two three:::four
+expected-stdout:
+       var=${a[*]}   ... one:::two:three:::four
+       var="${a[*]}" ... one:::two:three:::four
+       var=$*        ... one:::two:three:::four
+       var="$*"      ... one:::two:three:::four
+       var=${a[@]}   ... one:::two:three:::four
+       var="${a[@]}" ... one:::two three:::four
+       var=$@        ... one:::two:three:::four
+       var="$@"      ... one:::two three:::four
+---
 name: IFS-null-1
 description:
        Simple test, IFS=""
Index: eval.c
===================================================================
RCS file: /cvs/src/bin/mksh/eval.c,v
retrieving revision 1.137
diff -u -p -r1.137 eval.c
--- eval.c      23 Feb 2013 20:03:30 -0000      1.137
+++ eval.c      5 Mar 2013 16:07:35 -0000
@@ -865,6 +865,8 @@ expand(
                                        /* terminate word for "$@" */
                                        type = XARGSEP;
                                        quote = 0;
+                                       /* always space-separate words */
+                                       c = ' ';
                                }
                        }
                        break;

Reply via email to