On 12/3/2012 11:09 AM, rank1see...@gmail.com wrote:
> I've noticed this under 9.0-RELEASE-p5
> 
> 
> #!/bin/sh
> #####################################################
> ftest_dot ()
> {
>     local i
> 
>     for i in $*
>     {
>         echo "$i"
>     }
> }
> 
> ftest_monkey ()
> {
>     local i
> 
>     for i in $@
>     {
>         echo "$i"
>     }
> }
> 

From my understanding, used in that context, they should be the same.

      $*      Expands to the positional parameters, starting from one.  When
              the expansion occurs within a double-quoted string it
expands to
              a single field with the value of each parameter separated
by the
              first character of the IFS variable, or by a space if IFS is
              unset.

      $@      Expands to the positional parameters, starting from one.  When
              the expansion occurs within double-quotes, each positional
param‐
              eter expands as a separate argument.  If there are no
positional
              parameters, the expansion of @ generates zero arguments, even
              when @ is double-quoted.  What this basically means, for
example,
              is if $1 is “abc” and $2 is “def ghi”, then "$@" expands
to the
              two arguments:

                    "abc"   "def ghi"


Note the first sentence in both. The difference only occurs when used
inside quotes, i.e. "$@" and "$*"

Bryan
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to