bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] tests/test-xalloc-die.sh: Use $EXEEXT.


From: Jim Meyering
Subject: Re: [PATCH] tests/test-xalloc-die.sh: Use $EXEEXT.
Date: Sat, 13 Feb 2010 17:38:38 +0100

Eric Blake wrote:

> According to Jim Meyering on 2/13/2010 7:55 AM:
>>> For negated character classes in shell case statements, POSIX says to use
>>> [!a-z], not [^a-z].
>>
>> I've made that change, too.
>> Does it matter in practice?
>
> It matters for at least Solaris /bin/sh.
>
> $ /bin/sh -c 'case a in [^b]) echo yes;; *) echo no;; esac'
> /bin/sh: syntax error at line 1: `^' unexpected
> $ /bin/sh -c 'case a in [!b]) echo yes;; *) echo no;; esac'
> yes
>
> But that particular example is a moot point, given the use of $().
>
>> That's certainly more efficient.
>> Since it's less readable to me, I've added a comment.
>
> Indeed.  And it still needs a tweak:
>
>> +      *) # Remove leading file name components as well as the .exe suffix.
>> +         feb_file_=${${feb_file_##*/}%.exe}
>>       feb_result_="$feb_result_$feb_sp_$feb_file_";;
>
> Won't work as written, the % operator only works on variable names, but
> ${feb_file_##*/} is not a variable name.  Instead, you need an
> intermediate store:
>
> feb_file_=${feb_file_%.exe}
> feb_file_=${feb_file_##*/}

Ha! ;-)  I even thought of that, but tried what I wrote,
and it worked for me.  My error was to use zsh.

Normally I know better than to use that shell as a reference.
dash is generally good.
What we really need is a unit test to exercise init.sh.

BTW, I prefer to remove the usually-larger leading components first,
to avoid processing that part twice.

Thanks.  I'll squash this onto the previous:

diff --git a/tests/init.sh b/tests/init.sh
index fc2796a..951ec78 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -106,8 +106,9 @@ find_exe_basenames_()
     case $feb_file_ in
       *[!-a-zA-Z/0-9_.+]*) feb_fail_=1; break;;
       *) # Remove leading file name components as well as the .exe suffix.
-         feb_file_=${${feb_file_##*/}%.exe}
-        feb_result_="$feb_result_$feb_sp_$feb_file_";;
+         feb_file_=${feb_file_##*/}
+         feb_file_=${feb_file_%.exe}
+         feb_result_="$feb_result_$feb_sp_$feb_file_";;
     esac
     feb_sp_=' '
   done




reply via email to

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