From 09ed4de6388874e510cbd3ccadf23b4780f26130 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 3 Aug 2022 10:43:03 +0200 Subject: [PATCH 1/2] Fix errors and warnings raised by ShellCheck --- src/utils/scripts/download-galileo-almanac.sh | 27 ++++++++++--------- src/utils/scripts/gnss-sdr-harness.sh | 8 +++--- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/utils/scripts/download-galileo-almanac.sh b/src/utils/scripts/download-galileo-almanac.sh index 56202f65b..43b6621b6 100755 --- a/src/utils/scripts/download-galileo-almanac.sh +++ b/src/utils/scripts/download-galileo-almanac.sh @@ -35,16 +35,11 @@ help() echo " ./download-galileo-almanac.sh -rd 2022-03-15 # Gets Galileo Almanac XML file for that day, stores it as gal_almanac.xml" } -if (([ "$1" = "-h" ]) || ([ "$1" = "--help" ])) ; then +if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then help exit 0 fi -RENAME="" -if (([ "$1" = "-r" ]) || ([ "$1" = "--rename" ])) ; then - RENAME=" -O gal_almanac.xml " -fi - BASE_URL="https://www.gsc-europa.eu/sites/default/files/sites/all/files/" YEAR=$(date '+%Y') SPACING="-" @@ -57,7 +52,7 @@ TERMINATION2=".xml" COUNTER=1 MAX_COUNTER=7 -if (([ "$1" = "-d" ]) || ([ "$1" = "--date" ])) ; then +if [ "$1" = "-d" ] || [ "$1" = "--date" ] ; then if wget "$BASE_URL$2$TERMINATION2" >/dev/null 2>&1 ; then echo "Downloaded latest Galileo almanac from $BASE_URL$2$TERMINATION2" exit 0 @@ -78,12 +73,16 @@ else echo "According to system time, today is $(date '+%Y-%m-%d'). Searching for the latest Galileo almanac ..." fi +if [ "$1" = "-r" ] || [ "$1" = "--rename" ]; then + RENAME="yes" +fi + lowercase() { echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/" } -OS=`lowercase \`uname\`` +OS=$(lowercase "$(uname)") date_before() { @@ -96,16 +95,21 @@ date_before() MONTH=$(date -d "$COUNTER day ago" '+%m') DAY=$(date -d "$COUNTER day ago" '+%d') fi - COUNTER=$(($COUNTER+1)) + COUNTER=$((COUNTER+1)) } +download_rename_file() +{ + [ "$RENAME" = "yes" ] && set -- -O gal_almanac.xml "$@" + wget "$@" +} try_download() { while [ $COUNTER -le $MAX_COUNTER ] do url="$BASE_URL$YEAR$SPACING$MONTH$SPACING$DAY$TERMINATION2" - if wget $RENAME $url >/dev/null 2>&1 ; then + if download_rename_file "$url" >/dev/null 2>&1 ; then echo "Downloaded latest Galileo almanac from $url" exit 0 else @@ -115,9 +119,8 @@ try_download() done } - url="$BASE_URL$YEAR$SPACING$MONTH$SPACING$DAY$TERMINATION1" -if wget $RENAME $url >/dev/null 2>&1 ; then +if download_rename_file "$url" >/dev/null 2>&1 ; then echo "Downloaded latest Galileo almanac from $url" else try_download diff --git a/src/utils/scripts/gnss-sdr-harness.sh b/src/utils/scripts/gnss-sdr-harness.sh index 122fdafc5..b3d823333 100755 --- a/src/utils/scripts/gnss-sdr-harness.sh +++ b/src/utils/scripts/gnss-sdr-harness.sh @@ -5,10 +5,10 @@ # SPDX-FileCopyrightText: Javier Arribas # SPDX-License-Identifier: GPL-3.0-or-later -echo $@ -$@ +echo "Executing" "$@" +"$@" while [ $? -eq 42 ] do - echo "restarting GNSS-SDR..." - $@ + echo "Restarting GNSS-SDR..." + "$@" done From 73fb017a0a3ab58b79b5185d7d0aaf196cbb82a7 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 3 Aug 2022 12:33:57 +0200 Subject: [PATCH 2/2] CI: add shellcheck work --- .github/workflows/main.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 268ec1b46..cc27accc3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -182,6 +182,16 @@ jobs: run: cd build && ctest -C Release --exclude-regex volk_gnsssdr_32fc_32f_rotator_dotprodxnpuppet_32fc + shellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: install dependencies + run: sudo apt install shellcheck + - name: check scripts + run: shellcheck src/utils/scripts/* + + REUSE-compliance: runs-on: ubuntu-latest steps: