[Intel-gfx] [PATCH i-g-t] igt_command_line.sh: Fix bashism
Jani Nikula
jani.nikula at linux.intel.com
Mon Sep 25 11:48:41 UTC 2017
On Mon, 25 Sep 2017, Petri Latvala <petri.latvala at intel.com> 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 at ffwll.ch>
> Signed-off-by: Petri Latvala <petri.latvala at intel.com>
> ---
> 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
More information about the Intel-gfx
mailing list