automake-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] tests: avoid one last `...` command substitution in 'test-in


From: Stefano Lattarini
Subject: Re: [PATCH] tests: avoid one last `...` command substitution in 'test-init.sh'
Date: Sat, 23 Jun 2012 00:28:07 +0200

Hi Eric.

On 06/23/2012 12:17 AM, Eric Blake wrote:
> On 06/22/2012 04:13 PM, Stefano Lattarini wrote:
>> * t/ax/test-init.sh (me): In the definition of this variable.  This
>> also shave off a couple of forks, and the need for a sanity check
>> only required in fringe situations.
>>
>> Signed-off-by: Stefano Lattarini <address@hidden>
>> ---
>>  t/ax/test-init.sh |   11 +++++++----
>>  1 file changed, 7 insertions(+), 4 deletions(-)
>>
>> diff --git a/t/ax/test-init.sh b/t/ax/test-init.sh
>> index ca606b5..116d4b1 100644
>> --- a/t/ax/test-init.sh
>> +++ b/t/ax/test-init.sh
>> @@ -26,10 +26,13 @@ set -e
>>  # Test scripts can override it if they need to (but this should
>>  # be done carefully).
>>  if test -z "$me"; then
>> -  # Guard against failure to spawn sed (seen on MSYS), or empty $argv0.
>> -  me=`echo "$argv0" | sed -e 's,.*[\\/],,;s/\.sh$//;s/\.tap$//'` \
>> -    && test -n "$me" \
>> -    || { echo "$argv0: failed to define \$me" >&2; exit 99; }
>> +  # Strip all directory components.
>> +  me=${argv0##*/}
> 
> Should this strip to the last [\\/] instead of /?
>
Hrm, right.  But then, is something like '${argv0##*[\\/]`' actually portable
to all decent shells?  Not sure.  And AFAIU, the only way a '\' character can
end up in the $argv0 variable (that is just $0 "sanitized" for Zsh) is that
the user, *on MinGW/MSYS or Cygwin* manually invokes a test as, say,

  $ .\\t\\foo.sh

or

  $ make check TESTS='t\foo.sh'

which is clearly asking for trouble.  So: don't do that, or you'll be larted.

Of course, I'm ready to revisit this position if there will be real reports
from real users/developers; until then, I'd keep the simpler idiom above.  OK?

Thanks,
  Stefano



reply via email to

[Prev in Thread] Current Thread [Next in Thread]