[Intel-gfx] [PATCH i-g-t] igt_command_line.sh: Fix bashism
Daniel Vetter
daniel at ffwll.ch
Tue Sep 26 12:01:46 UTC 2017
On Mon, Sep 25, 2017 at 02:48:41PM +0300, Jani Nikula wrote:
> 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.
Yeah, let's just switch to /bin/bash and stop bothering with dash. At
least I don't see any value in trying to be posix compliant, we're not
going to run on anything that doesn't have bash anyway.
-Daniel
>
> 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
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
More information about the Intel-gfx
mailing list