From 90eb339a054645c66e30c6524250156cbfb001e3 Mon Sep 17 00:00:00 2001 From: Alexander Shaduri Date: Sat, 29 Jan 2022 21:12:36 +0400 Subject: [PATCH] Fixed Codacy warnings in shell scripts. --- contrib/cron-based_noadmin/cron_gather_smart.sh | 8 ++++---- contrib/cron-based_noadmin/smartctl_subst.sh | 6 +++--- data/gsmartcontrol-root.in.sh | 15 ++++++--------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/contrib/cron-based_noadmin/cron_gather_smart.sh b/contrib/cron-based_noadmin/cron_gather_smart.sh index 080daae..78ad03f 100755 --- a/contrib/cron-based_noadmin/cron_gather_smart.sh +++ b/contrib/cron-based_noadmin/cron_gather_smart.sh @@ -2,8 +2,8 @@ ############################################################################### # License: BSD Zero Clause License file # Copyright: -# (C) 2008 - 2021 Alex Butcher -# (C) 2008 - 2021 Alexander Shaduri +# (C) 2008 - 2022 Alex Butcher +# (C) 2008 - 2022 Alexander Shaduri ############################################################################### device="$1"; @@ -13,10 +13,10 @@ if [ "$device" = "" ]; then exit 1; fi -dev_base="`basename \"$device\"`" +dev_base=$(basename "$device") out_file=/var/run/smart-"$dev_base" # Change the path to smartctl if necessary. -smartctl -x "$device" 2>&1 > "$out_file" +smartctl -x "$device" > "$out_file" 2>&1 chmod 644 "$out_file" diff --git a/contrib/cron-based_noadmin/smartctl_subst.sh b/contrib/cron-based_noadmin/smartctl_subst.sh index 39f3fd1..589bab0 100755 --- a/contrib/cron-based_noadmin/smartctl_subst.sh +++ b/contrib/cron-based_noadmin/smartctl_subst.sh @@ -2,8 +2,8 @@ ############################################################################### # License: BSD Zero Clause License file # Copyright: -# (C) 2008 - 2021 Alex Butcher -# (C) 2008 - 2021 Alexander Shaduri +# (C) 2008 - 2022 Alex Butcher +# (C) 2008 - 2022 Alexander Shaduri ############################################################################### if [ "$1" = "-V" ]; then @@ -21,7 +21,7 @@ if [ "$device" = "" ]; then exit 1; fi -dev_base="`basename \"$device\"`" +dev_base=$(basename "$device") out_file=/var/run/smart-"$dev_base" cat "$out_file" diff --git a/data/gsmartcontrol-root.in.sh b/data/gsmartcontrol-root.in.sh index 6f86c2c..1f123c9 100644 --- a/data/gsmartcontrol-root.in.sh +++ b/data/gsmartcontrol-root.in.sh @@ -2,14 +2,14 @@ ############################################################################### # License: Zlib # Copyright: -# (C) 2008 - 2021 Alexander Shaduri +# (C) 2008 - 2022 Alexander Shaduri ############################################################################### # Run gsmartcontrol with root, asking for root password first. # export GSMARTCONTROL_SU to override a su command (e.g. "kdesu -c"). EXEC_BIN="@CMAKE_INSTALL_FULL_SBINDIR@/gsmartcontrol"; -prog_name="gsmartcontrol" +program_name="gsmartcontrol" # Preserve quotes in arguments @@ -30,7 +30,7 @@ else # New syntax: # gsmartcontrol-root [--desktop=] [program_options] - for arg in $*; do + for arg in "$@"; do case $arg in --desktop=*) DESKTOP="${arg#*=}"; @@ -45,7 +45,7 @@ fi if [ "$DESKTOP" != "auto" ] && [ "$DESKTOP" != "kde" ] && \ [ "$DESKTOP" != "gnome" ] && [ "$DESKTOP" != "other" ]; then - echo "Usage: $0 [--desktop=] [<${prog_name}_options>]"; + echo "Usage: $0 [--desktop=] [<${program_name}_options>]"; exit 1; fi @@ -101,7 +101,7 @@ if [ "$GSMARTCONTROL_SU" = "" ]; then done if [ "$found_su" = "" ]; then - xmessage "Error launching ${prog_name}: No suitable su mechanism found. + xmessage "Error launching ${program_name}: No suitable su mechanism found. Try installing PolKit, kdesu, gnomesu, gksu, beesu or sux first."; exit 1; fi @@ -164,8 +164,5 @@ fi # echo $full_cmd -eval $full_cmd - - - +eval "$full_cmd"