Re: [PATCH 15/16] Revert and amend "test-lib-functions: assert correct parameter count"
On Apr 15 2021, Ævar Arnfjörð Bjarmason wrote:
Show 32 quoted lines
> On Mon, Apr 12 2021, Junio C Hamano wrote:
>
>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>>
>>> test_path_is_file () {
>>> - test "$#" -ne 1 && BUG "1 param"
>>> - if ! test -f "$1"
>>> + if ! test -f "$@"
>>> then
>>> - echo "File $1 doesn't exist"
>>> + echo "File $@ doesn't exist"
>>> return 1
>>
>> What does it even mean to call
>>
>> test_path_is_file Documentation/ Makefile
>>
>> with this patch applied?
>>
>> If there were three files "COPYING Makefile", "COPYING", and
>> "Makefile", what would happen when you did
>>
>> test_path_is_file COPYING Makefile
>>
>> (without dq around them)?
>>
>> I think this particular medicine is far worse than the symptom it
>> tries to cure.
>
> We'll error with:
>
> test: foo: unexpected operatorIf you want a single argument you should use "$*", not "$@".
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."