summaryrefslogtreecommitdiff
path: root/src/chroot-tools/librechroot
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-04-15 17:37:46 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-04-15 17:37:46 -0400
commitbb819d5ef6c6dc68da524de07991eae2a2c3a3af (patch)
treefb5349192696db11086dc85820b0bf4b4e5d6c95 /src/chroot-tools/librechroot
parent7bd29f4570869e1db2992e337f86e93f1cfa43e7 (diff)
Use a better technique for dealing with empty arrays when `set -u`.
https://news.ycombinator.com/item?id=11497636
Diffstat (limited to 'src/chroot-tools/librechroot')
-rwxr-xr-xsrc/chroot-tools/librechroot16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index 5ff9c99..ba722c7 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -54,18 +54,22 @@ arch-nspawn() {
local copydir=$1; shift
local cmd=("$@")
- set +u # if an array is empty, it counts as unbound
- "$_arch_nspawn" "${arch_nspawn_flags[@]}" "$copydir" "${sysd_nspawn_flags[@]}" -- "${cmd[@]}"
- set -u
+ "$_arch_nspawn" \
+ ${arch_nspawn_flags+"${arch_nspawn_flags[@]}"} \
+ "$copydir" \
+ ${sysd_nspawn_flags+"${sysd_nspawn_flags[@]}"} \
+ -- \
+ "${cmd[@]}"
}
# Usage: mkarchroot $copydir $pkgs...
mkarchroot() {
local copydir=$1; shift
local pkgs=("$@")
- set +u # if an array is empty, it counts as unbound
- "$_mkarchroot" "${arch_nspawn_flags[@]}" "$copydir" "${pkgs[@]}"
- set -u
+ "$_mkarchroot" \
+ ${arch_nspawn_flags+"${arch_nspawn_flags[@]}"} \
+ "$copydir" \
+ "${pkgs[@]}"
}
# Usage: _makechrootpkg $function $arguments...