usr_bin/grml-exec-wrapper: Fix a couple of shellcheck warnings
authorDarshaka Pathirana <dpat@syn-net.org>
Fri, 4 Dec 2020 10:00:08 +0000 (11:00 +0100)
committerDarshaka Pathirana <dpat@syn-net.org>
Fri, 3 Dec 2021 11:54:54 +0000 (12:54 +0100)
- SC2059: Don't use variables in the printf format string.
- SC2086: Double quote to prevent globbing and word splitting.
- SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.

Please note that SC2059 causes SC1117 (Backslash is literal in "\n".
Prefer explicit escaping: "\\n") in shellcheck 0.5.0 an below.

This check was retired due to noise in koalaman/shellcheck@d8a32da07.

usr_bin/grml-exec-wrapper

index d3ff8ee..4e5a3cc 100755 (executable)
@@ -6,15 +6,16 @@
 # License:       This file is licensed under the GPL v2 or any later version.
 ################################################################################
 
+PN=$(basename "$0")
+
 usage() {
-  printf "Usage: $0 <program> [<arguments>]
+  printf "Usage: %s <program> [<arguments>]
 
 Available options:
 
   -h | --help   display this usage information
   -p <program>  check specified argument instead of default args, like:
-                $(basename $0) -p aumix xterm -T aumix -e aumix
-"
+                %s -p aumix xterm -T aumix -e aumix\n" "${PN}" "${PN}"
 }
 
 is_installed() {
@@ -49,7 +50,7 @@ else
 fi
 }
 
-if [ -z "$1" -o "$1" = '-h' -o "$1" = '--help' ] ; then
+if [ -z "$1" ] || [ "$1" = '-h' ] || [ "$1" = '--help' ] ; then
     usage
     exit 1
 fi
@@ -80,7 +81,7 @@ Looks like the grml flavour you are using does not ship ${PROG}. :(
 
 You can search for ${PROG} executing:
 
-apt-get update && apt-cache search $(basename ${PROG})
+apt-get update && apt-cache search $(basename "${PROG}")
     "
 
 exit 1