[PATCH] *.sh: Fix kornsh-ism test(1) invocations
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Wed Sep 14 05:29:59 PDT 2022
s/==/=/g
s/]]/]/g
s/\[\[/[/g
The POSIXly correct shorthand of test(1) is [, not [[
and string comparison is POSIXly correct =, not ==.
---
android/fetch.sh | 4 ++--
trojans/csd-post.sh | 8 ++++----
trojans/csd-wrapper.sh | 24 ++++++++++++------------
3 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/android/fetch.sh b/android/fetch.sh
index 9012eec5..97a87c0b 100755
--- a/android/fetch.sh
+++ b/android/fetch.sh
@@ -51,7 +51,7 @@ function make_url
local pkg="${tarball%-*}"
pkg="${pkg/-/_}"
- if [[ "$pkg" =~ [^[:alnum:]_] ]]; then
+ if [ "$pkg" =~ [^[:alnum:]_] ]; then
echo ""
return
fi
@@ -64,7 +64,7 @@ function make_url
return
fi
- if [[ "${mirror_base}" = *//github.com*/archive* ]]; then
+ if [ "${mirror_base}" = *//github.com*/archive* ]; then
# typical format: https://github.com/USER/PKG/archive/TAG.tar.gz
echo "${mirror_base}/${tarball#*-}"
else
diff --git a/trojans/csd-post.sh b/trojans/csd-post.sh
index b7c935ac..fb18f2da 100755
--- a/trojans/csd-post.sh
+++ b/trojans/csd-post.sh
@@ -26,12 +26,12 @@ fi
# to true if using an earlier version of cURL.
MISSING_OPTION_PINNEDPUBKEY=false
-if [[ "$MISSING_OPTION_PINNEDPUBKEY" == "true" ]]; then
+if [ "$MISSING_OPTION_PINNEDPUBKEY" = "true" ]; then
echo "*********************************************************************" >&2
echo "WARNING: running insecurely; will not validate CSD server certificate" >&2
echo "*********************************************************************" >&2
PINNEDPUBKEY="-k"
-elif [[ -z "$CSD_SHA256" ]]; then
+elif [ -z "$CSD_SHA256" ]; then
# We must be running with a version of OpenConnect prior to v8.00 if CSD_SHA256
# is unset. In that case, fallback to cURL's default certificate validation so
# as to fail-closed rather than fail-open in the case of an unknown or untrusted
@@ -91,8 +91,8 @@ TICKET=
STUB=0
while [ "$1" ]; do
- if [ "$1" == "-ticket" ]; then shift; TICKET=${1//\"/}; fi
- if [ "$1" == "-stub" ]; then shift; STUB=${1//\"/}; fi
+ if [ "$1" = "-ticket" ]; then shift; TICKET=${1//\"/}; fi
+ if [ "$1" = "-stub" ]; then shift; STUB=${1//\"/}; fi
shift
done
diff --git a/trojans/csd-wrapper.sh b/trojans/csd-wrapper.sh
index 275b7ecc..b6187cee 100755
--- a/trojans/csd-wrapper.sh
+++ b/trojans/csd-wrapper.sh
@@ -21,13 +21,13 @@ BIN_DIR="$HOSTSCAN_DIR/bin"
# to true if using an earlier version of cURL.
MISSING_OPTION_PINNEDPUBKEY=false
-if [[ "$MISSING_OPTION_PINNEDPUBKEY" == "true" ]]; then
+if [ "$MISSING_OPTION_PINNEDPUBKEY" = "true" ]; then
# Don't validate server certificate at all
echo "*********************************************************************" >&2
echo "WARNING: running insecurely; will not validate CSD server certificate" >&2
echo "*********************************************************************" >&2
PINNEDPUBKEY="-k"
-elif [[ -z "$CSD_SHA256" ]]; then
+elif [ -z "$CSD_SHA256" ]; then
# We must be running with a version of OpenConnect prior to v8.00 if CSD_SHA256
# is unset. In that case, fallback to cURL's default certificate validation so
# as to fail-closed rather than fail-open in the case of an unknown or untrusted
@@ -52,18 +52,18 @@ CERTHASH=
LANGSELEN=
while [ "$1" ]; do
- if [ "$1" == "-ticket" ]; then shift; TICKET=$1; fi
- if [ "$1" == "-stub" ]; then shift; STUB=$1; fi
- if [ "$1" == "-group" ]; then shift; GROUP=$1; fi
- if [ "$1" == "-certhash" ]; then shift; CERTHASH=$1; fi
- if [ "$1" == "-url" ]; then shift; URL=$(echo $1|tr -d '"'); fi # strip quotes
- if [ "$1" == "-langselen" ];then shift; LANGSELEN=$1; fi
+ if [ "$1" = "-ticket" ]; then shift; TICKET=$1; fi
+ if [ "$1" = "-stub" ]; then shift; STUB=$1; fi
+ if [ "$1" = "-group" ]; then shift; GROUP=$1; fi
+ if [ "$1" = "-certhash" ]; then shift; CERTHASH=$1; fi
+ if [ "$1" = "-url" ]; then shift; URL=$(echo $1|tr -d '"'); fi # strip quotes
+ if [ "$1" = "-langselen" ];then shift; LANGSELEN=$1; fi
shift
done
ARCH=$(uname -m)
-if [[ "$ARCH" == "x86_64" ]]
+if [ "$ARCH" = "x86_64" ]
then
ARCH="linux_x64"
else
@@ -72,7 +72,7 @@ fi
# creating dirs
for dir in $HOSTSCAN_DIR $LIB_DIR $BIN_DIR ; do
- if [[ ! -f $dir ]]
+ if [ ! -f $dir ]
then
mkdir -p $dir
fi
@@ -121,10 +121,10 @@ while read HASHTYPE FILE EQU HASHVAL; do
curl $PINNEDPUBKEY -s "${URL}/sdesktop/hostscan/$ARCH/$FILE" -o "${TMPFILE}"
# some files are in gz (don't understand logic here)
- if [[ ! -f "${TMPFILE}" || ! -s "${TMPFILE}" ]]
+ if [ ! -f "${TMPFILE}" || ! -s "${TMPFILE}" ]
then
# remove 0 size files
- if [[ ! -s ${TMPFILE} ]]; then
+ if [ ! -s ${TMPFILE} ]; then
rm ${TMPFILE}
fi
--
2.37.2
More information about the openconnect-devel
mailing list