From 1c3edd8d6b3415b990943b3a2525c72a53b1056f Mon Sep 17 00:00:00 2001 From: Darshaka Pathirana Date: Fri, 5 Mar 2021 16:55:58 +0100 Subject: [PATCH] usr_sbin/grml-setkeyboard: Fix a couple of shellcheck warnings - SC2086: Double quote to prevent globbing and word splitting. - Ignore SC1091: Not following: /etc/grml/script-functions was not specified as input (see shellcheck -x). - SC2086: Double quote to prevent globbing and word splitting. - SC2086: Double quote to prevent globbing and word splitting. - SC2086: Double quote to prevent globbing and word splitting. - SC2086: Double quote to prevent globbing and word splitting. - Ignore SC1091: Not following: /etc/sysconfig/keyboard was not specified as input (see shellcheck -x). - Ignore SC1010: Use semicolon or linefeed before 'fi' (or quote to make it literal). - Ignore SC1091: Not following: /etc/grml/language-functions was not specified as input (see shellcheck -x). --- usr_sbin/grml-setkeyboard | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/usr_sbin/grml-setkeyboard b/usr_sbin/grml-setkeyboard index 0ee4eab..ad2366c 100755 --- a/usr_sbin/grml-setkeyboard +++ b/usr_sbin/grml-setkeyboard @@ -6,10 +6,11 @@ # License: This file is licensed under the GPL v2. ################################################################################ -PN="$(basename $0)" +PN="$(basename "$0")" DIALOG=dialog CMDLINE=/proc/cmdline +# shellcheck disable=SC1091 . /etc/grml/script-functions check4root || exit 1 @@ -17,10 +18,10 @@ check4root || exit 1 setvalue(){ [ -n "$2" ] || return 1 # already present in conffile? - if grep -q ${1} $CONFFILE ; then - sed -i "s#^${1}.*#${1}=${2}#" $CONFFILE + if grep -q "${1}" "$CONFFILE" ; then + sed -i "s#^${1}.*#${1}=${2}#" "$CONFFILE" else - echo "$1=${2}" >> $CONFFILE + echo "$1=${2}" >> "$CONFFILE" fi } @@ -39,6 +40,7 @@ getbootparam(){ return 0 } +# shellcheck disable=SC1091 [ -r /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard [ -n "$KEYTABLE" ] && DEFAULT_KEYBOARD="$KEYTABLE" @@ -49,6 +51,8 @@ if [ -z "$DEFAULT_KEYBOARD" ] ; then fi fi +# shellcheck disable=SC1010 +{ LANGUAGE=$(LANG=C $DIALOG --stdout --title "$PN" --default-item $DEFAULT_KEYBOARD --radiolist \ "Which keyboard layout do you want to use? @@ -85,6 +89,7 @@ Configuration will be written to /etc/sysconfig/keyboard" 0 0 0 \ tw "chinese (traditional)" off \ uk british off \ ) +} retval=$? case $retval in @@ -96,7 +101,8 @@ case $retval in esac # read in the file where all the $LANGUAGE stuff is defined - . /etc/grml/language-functions +# shellcheck disable=SC1091 +. /etc/grml/language-functions cat > /etc/sysconfig/keyboard <