Skip to content

Commit a7c345d

Browse files
authored
Merge pull request #271 from austin987/sc2
misc shellcheck fixes
2 parents b53b22c + d6d142c commit a7c345d

File tree

5 files changed

+23
-14
lines changed

5 files changed

+23
-14
lines changed

filesystem/resources/pbuilder/hooks/D60no-man-db-rebuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
# Don't rebuild man-db
33

44
echo "I: Preseed man-db/auto-update to false"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
/usr/bin/apt-get update

initramfs/resources/initramfs-init

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#!/bin/busybox sh
2+
# shellcheck shell=sh
3+
# shellcheck disable=SC2039
4+
#
5+
# Really, this should be ash, not sh, but shellcheck doesn't support ash, see
6+
# https://github.com/koalaman/shellcheck/issues/853
7+
# SC2039 is there because of that (local/== unsupported in sh, work in ash)
28

39
# This is the init script built into the PrawnOS initramfs
410

@@ -21,8 +27,8 @@ echo In PrawnOS Init
2127

2228
#add this to start shell at desired point
2329
rescue_shell() {
24-
[ "{$1}" != "debug" ] && echo "Something went wrong. Dropping to a shell." > /dev/tty1
25-
[ "{$1}" == "debug" ] && echo "Debug flag detected, entering debug shell" > /dev/tty1
30+
[ "${1}" != "debug" ] && echo "Something went wrong. Dropping to a shell." > /dev/tty1
31+
[ "${1}" == "debug" ] && echo "Debug flag detected, entering debug shell" > /dev/tty1
2632
echo "Something went wrong. Dropping to a shell." > /dev/tty1
2733
exec setsid /bin/sh -c 'exec /bin/sh </dev/tty1 >/dev/tty1 2>&1'
2834
}
@@ -53,10 +59,12 @@ rootpartuuid() {
5359
# if optional count is provided:
5460
# returns 1 if substring occurs in string < optional count
5561
# returns 0 otherwise
56-
occur() while case "$1" in (*"$2"*) set -- \
62+
occur() {
63+
while case "$1" in (*"$2"*) set -- \
5764
"${1#*"$2"}" "$2" "${3:-0}" "$((${4:-0}+1))";;
5865
(*) return "$((${4:-0}<${3:-1}))";;esac
5966
do : "${_occur:+$((_occur=$4))}";done
67+
}
6068

6169
# mount the bare necesities
6270
mount -n -t proc proc /proc
@@ -93,22 +101,20 @@ fi
93101

94102
echo BLKID: ${BLKID} > /dev/tty1
95103

96-
#If its an mmcblk device, the kernel partiton will p1. If it is a usb device, the partiton will just be 1
97-
#Just want everything before the 1
104+
# If it's an mmcblk device, the kernel partiton will be p1. If it is a usb device, the partiton will just be 1.
105+
# Just want everything before the 1
98106
ROOT_DEV="${BLKID%1:*}"
99107
echo ROOT_DEV: ${ROOT_DEV} > /dev/tty1
100108

101109
# label any partition on the system with RESCUESHELL to enter the initramfs rescue shell before mount and root_switch.
102110
# you can do this with "cgpt add -i 1 -l RESCUESHELL /dev/sda" for example to label the first partiton of a usb drive.
103-
if [ -n "$(blkid | grep RESCUESHELL)" ]
104-
then
111+
if blkid | grep -q RESCUESHELL; then
105112
rescue_shell debug
106113
fi
107114

108115

109-
if [ -n "$(blkid ${ROOT_DEV}2 | grep crypto_LUKS)" ]
110-
then
111-
#decrypt and mount the root filesystem, disable kernel log messages to avoid clashing with the prompt
116+
if blkid ${ROOT_DEV}2 | grep -q crypto_LUKS; then
117+
# decrypt and mount the root filesystem, disable kernel log messages to avoid clashing with the prompt
112118
dmesg -n 2
113119
echo "Opening encrypted root partition, this will take 30s..."
114120
cryptsetup --tries 5 luksOpen ${ROOT_DEV}2 luksroot || rescue_shell

scripts/InstallScripts/InstallPackages.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#!/bin/bash -e
1+
#!/bin/bash
22

3+
set -e
34

45
# This file is part of PrawnOS (https://www.prawnos.com)
56
# Copyright (c) 2018 Hal Emmerich <[email protected]>

scripts/InstallScripts/InstallPrawnOS.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#!/bin/bash -e
1+
#!/bin/bash
2+
3+
set -e
24

35
#See the block of "echos" in main() for description of this script
46

0 commit comments

Comments
 (0)