summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2016-11-07 16:32:38 +0100
committerJonas Smedegaard <dr@jones.dk>2016-11-07 23:30:03 +0100
commit2fa4abcf69e7989d8e7e1d6bab23c2a70f13864a (patch)
tree2542d38b9232425bc8c58f33c96454712c37edda
parenta0d62f1c41fa22c501c8bcfa17e4131966917106 (diff)
Fail shell scripts on undefined variables (set -u).1.0b4
-rwxr-xr-xskel/multistrap-configure.sh8
-rwxr-xr-xskel/multistrap-hooks/completion_50_configscript.sh6
-rwxr-xr-xskel/multistrap-hooks/completion_90_chroot_cleanup.sh2
-rw-r--r--skel/script.sh.in2
4 files changed, 9 insertions, 9 deletions
diff --git a/skel/multistrap-configure.sh b/skel/multistrap-configure.sh
index 3bec557..69a11fb 100755
--- a/skel/multistrap-configure.sh
+++ b/skel/multistrap-configure.sh
@@ -10,7 +10,7 @@
#
# TODO: avoid need for libfakeroot installed into target system
-set -e
+set -eu
set -x
@@ -29,7 +29,7 @@ cat /tmp/preseeds/* 2>&- | debconf-set-selections
cat <<'EOF' >debconf-get
#!/bin/sh
# multistrap debconf wrapper to mimic d-i convenience command
-set -e
+set -eu
debconf-show d-i | grep -Po "(?<=. $1: ).*"
EOF
chmod +x debconf-get
@@ -95,7 +95,7 @@ adduser debian sudo
cat <<'EOF' > /root/init-network-settings
#!/bin/sh
-set -e
+set -eu
set -x
# Add static-IP internal first-port ethernet connection
@@ -133,7 +133,7 @@ chmod a+x /root/init-network-settings
cat <<'EOF' > /root/extend-partition
#!/bin/sh
-set -e
+set -eu
disk="${1:-/dev/mmcblk0}"
part="${2:-/dev/mmcblk0p2}"
diff --git a/skel/multistrap-hooks/completion_50_configscript.sh b/skel/multistrap-hooks/completion_50_configscript.sh
index d272529..ac69624 100755
--- a/skel/multistrap-hooks/completion_50_configscript.sh
+++ b/skel/multistrap-hooks/completion_50_configscript.sh
@@ -20,7 +20,7 @@
# * /usr/sbin/update-ca-certificates
# * /usr/bin/c_rehash
-set -e
+set -eu
set -x
fs="$1"
@@ -42,9 +42,9 @@ if [ "$arch" != "$arch_host" ]; then
fi
qemu=$(/usr/sbin/update-binfmts --display "qemu-$cpu" | grep -Po '(?<=interpreter = /usr/bin/).*') #'
fi
-if [ -n "$FAKEROOTKEY" ] && [ "$FAKECHROOT" != "true" ]; then
+if [ -n "${FAKEROOTKEY:-}" ] && [ "${FAKECHROOT:-}" != "true" ]; then
PATH=/usr/sbin:/usr/bin:/sbin:/bin \
- LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/$multiarch/libfakeroot" \
+ LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+LD_LIBRARY_PATH:}/usr/lib/$multiarch/libfakeroot" \
${qemu:+QEMU_LD_PREFIX="$fs"} \
proot -r "$fs" -b /proc -b /sys -b /dev ${qemu:+-q "$qemu"} -w / /multistrap-configure.sh
else
diff --git a/skel/multistrap-hooks/completion_90_chroot_cleanup.sh b/skel/multistrap-hooks/completion_90_chroot_cleanup.sh
index 67b6965..0a4e081 100755
--- a/skel/multistrap-hooks/completion_90_chroot_cleanup.sh
+++ b/skel/multistrap-hooks/completion_90_chroot_cleanup.sh
@@ -8,7 +8,7 @@
#
# Enhances: multistrap
-set -e
+set -eu
fs="$1"
diff --git a/skel/script.sh.in b/skel/script.sh.in
index 9c6941b..af2e0a8 100644
--- a/skel/script.sh.in
+++ b/skel/script.sh.in
@@ -4,7 +4,7 @@
# ShowMeBox Homepage: https://wiki.debian.org/ShowMeBox
# Source of this code: git://git.debian.org/showme/box
-set -e
+set -eu
[% pkgdesc %]
apt-get install [% pkglist %]