Skip to content

Commit

Permalink
usr_sbin/grml2ram: Fix a couple of shellcheck warnings
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
jkirk committed Dec 3, 2021
1 parent 96f6cc1 commit 3ace100
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions usr_sbin/grml2ram
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Filename: grml2ram
# Purpose: copy compressed GRML image to RAM
# Authors: (c) Michael Schierl <schierlm-public@gmx.de>, (c) Michael Prokop <mika@grml.org>
Expand All @@ -8,7 +8,9 @@

set -e

# shellcheck disable=SC1091
. /etc/grml/lsb-functions
# shellcheck disable=SC1091
. /etc/grml/script-functions

check4root || exit 1
Expand Down Expand Up @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 3ace100

Please sign in to comment.