[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [coreutils] [PATCH] tests: avoid portability problem with dash vs. l
From: |
Jim Meyering |
Subject: |
Re: [coreutils] [PATCH] tests: avoid portability problem with dash vs. local v=$splittable_val |
Date: |
Mon, 08 Nov 2010 12:51:23 +0100 |
Pádraig Brady wrote:
...
>>> diff --git a/tests/init.cfg b/tests/init.cfg
>>> index 1048cf3..d704f34 100644
>>> --- a/tests/init.cfg
>>> +++ b/tests/init.cfg
>>> @@ -388,8 +388,8 @@ retry_delay_()
>>> local num_sleeps=$attempt
>>> local time_fail
>>> while test $attempt -le $max_n_tries; do
>>> - local delay=$($AWK -v n=$num_sleeps -v s="$init_delay" \
>>> - 'BEGIN { for (i=0;i<n;i++) t = s" "t; print t }')
>>> + local delay=$($AWK -v n=$num_sleeps -v s=$init_delay \
>>> + 'BEGIN { print s*n }')
>>> "$test_func" "$delay" && { time_fail=0; break; } || time_fail=1
>>> attempt=$(expr $attempt + 1)
>>> num_sleeps=$(expr $num_sleeps '*' 2)
>>
>> I went for a slightly smaller change in your name.
>> If you'd like to remove the quotes around "$init_delay"
>> in a later change, please add a test like this to ensure
>> that it is a valid token (i.e., no white space):
>>
>> case $init_delay in
>> *[^+.0-9]*) skip_ "invalid delay: $init_delay; internal error, please
>> report"
>> esac
>>
>> I'll push this shortly.
>
> Well it's a very minor issue, but I removed the quotes
> so that we'd get an error if multiple params passed.
>
> d="1m 2s"
> awk -v n=4 -v s="$d" 'BEGIN { print s * n }'
> awk -v n=4 -v s=$d 'BEGIN { print s * n }'
>
> To be robust we'd need to restrict to a single seconds value.
> I'll fix that up after the release if I get bored.
That commit has your name on it, and it's not too late to change.
If you would prefer to remove the quotes and add the 3-line check
suggested above, that's ok with me, although I confess I haven't
tested this:
case $init_delay in
*[^+.0-9]*) skip_ "invalid delay: $init_delay; internal error, please report"
esac