Re: [PATCH i-g-t] igt_command_line.sh: Fix bashism

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

 



On Mon, 25 Sep 2017, Petri Latvala <petri.latvala@xxxxxxxxx> wrote:
> [[ a != b ]] is a bashism. As it's just comparing $1 to an empty
> string, use -n with a normal [ ].
>
> /bin/sh is dash in CI.

There's probably /bin/bash around anyway, but I'm tired of fighting the
fight. So never mind about that.

You could add shellcheck to your static checks, with a list of
exceptions of shellcheck tests you don't care about. It would tell you,

In igt_command_line.sh line 115:
if [[ "$1" != "" ]] ; then
   ^-- SC2039: In POSIX sh, [[ ]] is undefined.


BR,
Jani.


>
> Fixes: f0243a761f1b ("tests/igt_command_line.sh: Allow testing individual tests")
> CC: Daniel Vetter <daniel.vetter@xxxxxxxx>
> Signed-off-by: Petri Latvala <petri.latvala@xxxxxxxxx>
> ---
>  tests/igt_command_line.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/igt_command_line.sh b/tests/igt_command_line.sh
> index 57d105e9..a8baaaa1 100755
> --- a/tests/igt_command_line.sh
> +++ b/tests/igt_command_line.sh
> @@ -112,7 +112,7 @@ if [ $? -ne 0 ]; then
>  	exit 99
>  fi
>  
> -if [[ "$1" != "" ]] ; then
> +if [ -n "$1" ] ; then
>  	check_test $1
>  	exit 0
>  fi

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux