From 3ace1004ef0f658043f2645c46818d92ad66c0dc Mon Sep 17 00:00:00 2001 From: Darshaka Pathirana Date: Fri, 5 Mar 2021 15:37:36 +0100 Subject: [PATCH] usr_sbin/grml2ram: Fix a couple of shellcheck warnings - Ignore SC1091: Not following: /etc/grml/lsb-functions was not specified as input (see shellcheck -x). - Ignore SC1091: Not following: /etc/grml/script-functions was not specified as input (see shellcheck -x). - Set interpreter to /bin/bash because of SC2039: In POSIX sh, 'local' is undefined. - SC2086: Double quote to prevent globbing and word splitting. - SC2061: Quote the parameter to -name so the shell won't interpret it. - SC2086: Double quote to prevent globbing and word splitting. - SC2086: Double quote to prevent globbing and word splitting. - SC2015: Note that A && B || C is not if-then-else. C may run when A is true. --- usr_sbin/grml2ram | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/usr_sbin/grml2ram b/usr_sbin/grml2ram index 3482bdb..a4e119e 100755 --- a/usr_sbin/grml2ram +++ b/usr_sbin/grml2ram @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Filename: grml2ram # Purpose: copy compressed GRML image to RAM # Authors: (c) Michael Schierl , (c) Michael Prokop @@ -8,7 +8,9 @@ set -e +# shellcheck disable=SC1091 . /etc/grml/lsb-functions +# shellcheck disable=SC1091 . /etc/grml/script-functions check4root || exit 1 @@ -50,7 +52,7 @@ getbootparam(){ MEDIA_PATH="$(getbootparam live-media-path)" MEDIA_PATH="${MEDIA_PATH:-.}" -IMAGE=$(find ${LIVECD_PATH}/${MEDIA_PATH}/ -name *.squashfs 2>/dev/null | head -1) +IMAGE=$(find "${LIVECD_PATH}/${MEDIA_PATH}/" -name "*.squashfs" 2>/dev/null | head -1) if ! [ -r "$IMAGE" ] ; then if [ -r /cdrom/GRML/GRML ] ; then IMAGE='/cdrom/GRML/GRML' @@ -68,7 +70,7 @@ case "$*" in -f|--force) ewarn "Forcing copy process for grml-image (${GRMLSIZE}kB) as requested via force option." ; eend 0 ;; *) - if test $RAM -lt $GRMLSIZE ; then + if test "$RAM" -lt "$GRMLSIZE" ; then eerror "Sorry, not enough free RAM (${RAM}kB) available for grml-image (${GRMLSIZE}kB)." ; eend 1 exit 1 fi @@ -96,7 +98,12 @@ fi [ -n "$GRMLDEV" ] || GRMLDEV='/dev/cdrom' einfo "Unmounting cdrom" -[ -d $LIVECD_PATH ] && umount $LIVECD_PATH || umount /cdrom +if [ -d $LIVECD_PATH ] ; +then + umount $LIVECD_PATH +else + umount /cdrom +fi eend $? einfo "Now you can eject your grml-cd (e.g. run 'eject $GRMLDEV')." ; eend 0 -- 2.1.4