[glib: 2/5] ci: Fix various shellcheck warnings in the shell scripts



commit 23d26cfe7e4b270e77ccd6ac5c54c48cb783e1a6
Author: Philip Withnall <withnall endlessm com>
Date:   Tue Feb 25 11:46:11 2020 +0000

    ci: Fix various shellcheck warnings in the shell scripts
    
    I haven’t tested any of them. This is entirely mechanical. I used
    shellcheck 0.7.0 with default options.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 .gitlab-ci/android-download-ndk.sh | 10 +++++-----
 .gitlab-ci/android-setup-env.sh    | 14 +++++++-------
 .gitlab-ci/coverage-docker.sh      |  2 +-
 .gitlab-ci/run-check-todos.sh      |  2 +-
 .gitlab-ci/run-docker.sh           | 12 +++++++-----
 .gitlab-ci/run-style-check-diff.sh |  2 +-
 .gitlab-ci/run-tests.sh            |  2 +-
 .gitlab-ci/test-msys2.sh           | 17 +++++++++++------
 8 files changed, 34 insertions(+), 27 deletions(-)
---
diff --git a/.gitlab-ci/android-download-ndk.sh b/.gitlab-ci/android-download-ndk.sh
index 785ee0189..7739e39d5 100755
--- a/.gitlab-ci/android-download-ndk.sh
+++ b/.gitlab-ci/android-download-ndk.sh
@@ -24,8 +24,8 @@ set -e
 # Download Android NDK
 ANDROID_NDK_VERSION="r17b"
 
ANDROID_NDK_SHA512="062fac12f747730f5563995089a8b4abab683fbbc621aa8582fdf35fe327daee5d69ed2437af257c10ec4ef54ecd3805a8f134a1400eb8f34ee76f55c8dc9ae9"
-wget --quiet https://dl.google.com/android/repository/android-ndk-$ANDROID_NDK_VERSION-linux-x86_64.zip
-echo "$ANDROID_NDK_SHA512  android-ndk-$ANDROID_NDK_VERSION-linux-x86_64.zip" | sha512sum -c
-unzip android-ndk-$ANDROID_NDK_VERSION-linux-x86_64.zip
-rm android-ndk-$ANDROID_NDK_VERSION-linux-x86_64.zip
-mv android-ndk-$ANDROID_NDK_VERSION $ANDROID_NDK_PATH
+wget --quiet "https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip";
+echo "${ANDROID_NDK_SHA512}  android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip" | sha512sum -c
+unzip "android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip"
+rm "android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip"
+mv "android-ndk-${ANDROID_NDK_VERSION}" "${ANDROID_NDK_PATH}"
diff --git a/.gitlab-ci/android-setup-env.sh b/.gitlab-ci/android-setup-env.sh
index 60a86de19..bdbb958e3 100755
--- a/.gitlab-ci/android-setup-env.sh
+++ b/.gitlab-ci/android-setup-env.sh
@@ -27,7 +27,7 @@ toolchain_path=$(pwd)/android-toolchain-$arch-$api
 prefix_path=$(pwd)/android-$arch-$api
 
 # Create standalone toolchains
-$ANDROID_NDK_PATH/build/tools/make_standalone_toolchain.py --arch $arch --api $api --install-dir 
$toolchain_path
+"${ANDROID_NDK_PATH}/build/tools/make_standalone_toolchain.py" --arch "${arch}" --api "${api}" --install-dir 
"${toolchain_path}"
 
 target_host=aarch64-linux-android
 export AR=$target_host-ar
@@ -45,7 +45,7 @@ if [ "$api" -lt "28" ]; then
   echo 
"1233fe3ca09341b53354fd4bfe342a7589181145a1232c9919583a8c9979636855839049f3406f253a9d9829908816bb71fd6d34dd544ba290d6f04251376b1a
  libiconv-1.15.tar.gz" | sha512sum -c
   tar xzf libiconv-1.15.tar.gz
   pushd libiconv-1.15
-  ./configure --host=$target_host --prefix=$prefix_path  --libdir=$prefix_path/lib64
+  ./configure --host="${target_host}" --prefix="${prefix_path}"  --libdir="${prefix_path}/lib64"
   make
   make install
   popd
@@ -58,7 +58,7 @@ wget --quiet https://github.com/libffi/libffi/releases/download/v3.3-rc0/libffi-
 echo 
"e6e695d32cd6eb7d65983f32986fccdfc786a593d2ea18af30ce741f58cfa1eb264b1a8d09df5084cb916001aea15187b005c2149a0620a44397a4453b6137d4
  libffi-3.3-rc0.tar.gz" | sha512sum -c
 tar xzf libffi-3.3-rc0.tar.gz
 pushd libffi-3.3-rc0
-./configure --host=$target_host --prefix=$prefix_path --libdir=$prefix_path/lib64
+./configure --host="${target_host}" --prefix="${prefix_path}" --libdir="${prefix_path}/lib64"
 make
 make install
 popd
@@ -66,9 +66,9 @@ rm libffi-3.3-rc0.tar.gz
 rm -r libffi-3.3-rc0
 
 # Create a pkg-config wrapper that won't pick fedora libraries
-mkdir -p $prefix_path/bin
+mkdir -p "${prefix_path}/bin"
 export PKG_CONFIG=$prefix_path/bin/pkg-config
-cat > $PKG_CONFIG <<- EOM
+cat > "${PKG_CONFIG}" <<- EOM
 #!/bin/sh
 SYSROOT=${prefix_path}
 export PKG_CONFIG_DIR=
@@ -76,10 +76,10 @@ export PKG_CONFIG_LIBDIR=\${SYSROOT}/lib64/pkgconfig
 export PKG_CONFIG_SYSROOT_DIR=\${SYSROOT}
 exec pkg-config "\$@"
 EOM
-chmod +x $PKG_CONFIG
+chmod +x "${PKG_CONFIG}"
 
 # Create a cross file that can be passed to meson
-cat > cross_file_android_${arch}_${api}.txt <<- EOM
+cat > "cross_file_android_${arch}_${api}.txt" <<- EOM
 [host_machine]
 system = 'android'
 cpu_family = 'aarch64'
diff --git a/.gitlab-ci/coverage-docker.sh b/.gitlab-ci/coverage-docker.sh
index b6421be86..bf795619a 100755
--- a/.gitlab-ci/coverage-docker.sh
+++ b/.gitlab-ci/coverage-docker.sh
@@ -19,7 +19,7 @@ genhtml \
     -o _coverage/coverage
 
 cd _coverage
-rm -f *.lcov
+rm -f ./*.lcov
 
 cat >index.html <<EOL
 <html>
diff --git a/.gitlab-ci/run-check-todos.sh b/.gitlab-ci/run-check-todos.sh
index 786fd71d6..d29cfbf9e 100755
--- a/.gitlab-ci/run-check-todos.sh
+++ b/.gitlab-ci/run-check-todos.sh
@@ -12,5 +12,5 @@ git fetch upstream
 # `upstream/master` or `upstream/glib-2-62`).
 # `${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}` is only defined if we’re running in
 # a merge request pipeline; fall back to `${CI_DEFAULT_BRANCH}` otherwise.
-newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent 
upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}) <(git rev-list --first-parent HEAD) | 
head -1)
+newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent 
"upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent HEAD) 
| head -1)
 ./.gitlab-ci/check-todos.py "${newest_common_ancestor_sha}"
diff --git a/.gitlab-ci/run-docker.sh b/.gitlab-ci/run-docker.sh
index 5f03db853..9b6fce4bc 100755
--- a/.gitlab-ci/run-docker.sh
+++ b/.gitlab-ci/run-docker.sh
@@ -6,9 +6,9 @@ read_arg() {
     # $3 = arg parameter
     local rematch='^[^=]*=(.*)$'
     if [[ $2 =~ $rematch ]]; then
-        read "$1" <<< "${BASH_REMATCH[1]}"
+        read -r "$1" <<< "${BASH_REMATCH[1]}"
     else
-        read "$1" <<< "$3"
+        read -r "$1" <<< "$3"
         # There is no way to shift our callers args, so
         # return 1 to indicate they should do it instead.
         return 1
@@ -16,7 +16,7 @@ read_arg() {
 }
 
 SUDO_CMD="sudo"
-if `docker -v | grep -q podman` ; then
+if docker -v |& grep -q podman; then
         # Using podman
         SUDO_CMD=""
         # Docker is actually implemented by podman, and its OCI output
@@ -27,6 +27,8 @@ fi
 
 set -e
 
+base=""
+base_version=""
 build=0
 run=0
 push=0
@@ -79,7 +81,7 @@ if [ $list == 1 ]; then
 fi
 
 # All commands after this require --base to be set
-if [ -z $base ]; then
+if [ -z "${base}" ]; then
         echo "Usage: $0 <command>"
         exit 1
 fi
@@ -89,7 +91,7 @@ if [ ! -f "$base.Dockerfile" ]; then
         exit 1
 fi
 
-if [ -z $base_version ]; then
+if [ -z "${base_version}" ]; then
         base_version="latest"
 else
         base_version="v$base_version"
diff --git a/.gitlab-ci/run-style-check-diff.sh b/.gitlab-ci/run-style-check-diff.sh
index f2dd5f378..534698dc4 100755
--- a/.gitlab-ci/run-style-check-diff.sh
+++ b/.gitlab-ci/run-style-check-diff.sh
@@ -15,7 +15,7 @@ git fetch upstream
 # `upstream/master` or `upstream/glib-2-62`).
 # `${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}` is only defined if we’re running in
 # a merge request pipeline; fall back to `${CI_DEFAULT_BRANCH}` otherwise.
-newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent 
upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}) <(git rev-list --first-parent HEAD) | 
head -1)
+newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent 
"upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent HEAD) 
| head -1)
 git diff -U0 --no-color "${newest_common_ancestor_sha}" | ./clang-format-diff.py -binary "clang-format-7" -p1
 
 )
diff --git a/.gitlab-ci/run-tests.sh b/.gitlab-ci/run-tests.sh
index 539726e9a..b545a6f3c 100755
--- a/.gitlab-ci/run-tests.sh
+++ b/.gitlab-ci/run-tests.sh
@@ -14,7 +14,7 @@ esac
 
 meson test \
         -C _build \
-        --timeout-multiplier ${MESON_TEST_TIMEOUT_MULTIPLIER} \
+        --timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" \
         --no-suite flaky \
         "$@"
 
diff --git a/.gitlab-ci/test-msys2.sh b/.gitlab-ci/test-msys2.sh
index 34953d545..45a46165c 100755
--- a/.gitlab-ci/test-msys2.sh
+++ b/.gitlab-ci/test-msys2.sh
@@ -27,16 +27,21 @@ pacman --noconfirm -S --needed \
 curl -O -J -L "https://github.com/linux-test-project/lcov/releases/download/v1.14/lcov-1.14.tar.gz";
 echo "14995699187440e0ae4da57fe3a64adc0a3c5cf14feab971f8db38fb7d8f071a  lcov-1.14.tar.gz" | sha256sum -c
 tar -xzf lcov-1.14.tar.gz
-LCOV="$(pwd)/lcov-1.14/bin/lcov"
+# FIXME: not currently using lcov, see below
+#LCOV="$(pwd)/lcov-1.14/bin/lcov"
 
 mkdir -p _coverage
 mkdir -p _ccache
-export CCACHE_BASEDIR="$(pwd)"
-export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache"
+CCACHE_BASEDIR="$(pwd)"
+CCACHE_DIR="${CCACHE_BASEDIR}/_ccache"
+export CCACHE_BASEDIR CCACHE_DIR
+
 pip3 install --upgrade --user meson==0.49.2
-export PATH="$HOME/.local/bin:$PATH"
-export CFLAGS="-coverage -ftest-coverage -fprofile-arcs"
+
+PATH="$HOME/.local/bin:$PATH"
+CFLAGS="-coverage -ftest-coverage -fprofile-arcs"
 DIR="$(pwd)"
+export PATH CFLAGS
 
 meson --werror --buildtype debug _build
 cd _build
@@ -53,7 +58,7 @@ ninja
 #    --output-file "${DIR}/_coverage/${CI_JOB_NAME}-baseline.lcov"
 
 # FIXME: fix the test suite
-meson test --timeout-multiplier ${MESON_TEST_TIMEOUT_MULTIPLIER} --no-suite flaky || true
+meson test --timeout-multiplier "${MESON_TEST_TIMEOUT_MULTIPLIER}" --no-suite flaky || true
 
 python3 "${DIR}"/.gitlab-ci/meson-junit-report.py \
         --project-name glib \


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