Re: [PATCH 6/8] t/perf: add Scalar performance tests

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

 



"Victoria Dye via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:

> +test_compare_perf () {
> +	command="$@"
> +	test_perf "$command (scalar)" "
> +		(
> +			cd scalar-clone/src &&
> +			$command
> +		)
> +	"

Our preference is to avoid using "$@" when you are not taking
advantage of the fact that it protects individual parameters from
getting split at $IFS whitespaces.  Use "$*" is preferred here [*].

For example, this is good:

    mytest () {
        for arg in one two "$@" three
        do
            do_something_to "$arg"
        done
    }

    mytest 'a b c' 'd'

Thanks to the use of "$@", 'a b c' stays together and are kept
distinct from 'd'.

The above is not.  command="$@" is used as a misleading synonym for
command="$*" that flattens the arguments to test_compare_perf
function.  If you called it with 'a b c' and 'd' like we called
mytest with, you cannot tell that 'a b c' were together and 'd' was
distinct from the other three.  The only thing test_perf sees would
be that $command without double quotes have four separate tokens.


[Footnote]

* Of course, it is tolerated only in tests and perfs where we are in
  total control of the arguments so that we can declare that no args
  to the shell function have whitespace in them.  In scripts used by
  end-users, we may not be able to get away with "$*".



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux