[PATCH] *.sh: Fix kornsh-ism test(1) invocations

Dimitri Papadopoulos dimitri.papadopoulos at cea.fr
Thu Sep 15 02:54:39 PDT 2022

> Do note that all three of these scripts are explicitly intended+tested
> *only* to run under Bash…
>      $ head -n1 android/fetch.sh trojans/csd-*.sh
>      ==> android/fetch.sh <==
>      #!/bin/bash
>      ==> trojans/csd-post.sh <==
>      #!/bin/bash
>      ==> trojans/csd-wrapper.sh <==
>      #!/bin/bash
> Is there some specific environment where your modifications make them
> work with a "plain" POSIX sh, where they didn't previously work
> correctly?


Indeed why change something that works? Let's have a look at the 

   Compound Commands
     [[ expression ]]
         When the == and != operators are used, the string to the
         right of the operator is considered a pattern and matched
         according to the rules described below under Pattern
         Matching, as if the extglob shell option were enabled.
         The = operator is equivalent to ==.

         An additional binary operator, =~, is available, with the
         same precedence as == and !=.  When it is used, the string
         to the right of the operator is considered a POSIX
         extended regular expression and matched accordingly (using
         the POSIX regcomp and regexec interfaces usually described
         in regex(3)).

Perhaps the double [[ == ]] can be changed to [ = ] in most cases, as it 
implies regular expressions might be involved - but they are not.

Dimitri Papadopoulos

More information about the openconnect-devel mailing list