[x264-devel] [PATCH v2 2/8] configure: replace usage of [[ with POSIX-compatible [

Diego Biurrun diego at biurrun.de
Sat Jan 25 15:17:30 CET 2020


On 16/01/2020 22.23, Ethan Sommer wrote:
> ---
>   configure | 39 ++++++++++++++++++---------------------
>   1 file changed, 18 insertions(+), 21 deletions(-)
> 
> --- a/configure
> +++ b/configure
> @@ -78,13 +78,12 @@ cc_cflags() {
>       for arg in $*; do
> -        [[ "$arg" = -falign-loops* ]] && arg=
> +        [ "${arg#-falign-loops}" = "$arg" ] || arg=

Doesn't look equivalent to me.

In any case this patch is much too clever for my taste. You can do 
pattern matching in POSIX shell, that's what the case statement is for. 
The problem I see here is the ugly pattern matching in if-statements + 
bash extensions. These blocks should be rewritten as case-statements 
instead.

> @@ -107,7 +106,7 @@ cc_cflags() {
>   cl_ldflags() {
>       for arg in $*; do
>           arg=${arg/LIBPATH/libpath}
> -        [ "${arg#-libpath:}" == "$arg" -a "${arg#-l}" != "$arg" ] && arg=${arg#-l}.lib
> +        [ "${arg#-libpath:}" = "$arg" -a "${arg#-l}" != "$arg" ] && arg=${arg#-l}.lib

This is an unrelated change; if you have to fold it into a patch it 
should be inside the one that touches this line anyway to eliminate the 
'-a'.

> @@ -951,7 +948,7 @@ fi
>   
>   if [ $asm = auto -a $ARCH = ARM ] ; then
>       # set flags so neon is built by default
> -    [ $compiler == CL ] || echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon"
> +    [ $compiler = CL ] || echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon"

Same; you are also replacing == by = here.

Diego


More information about the x264-devel mailing list