diff options
| author | Tails developers <amnesia@boum.org> | 2012-12-07 22:31:36 +0100 |
|---|---|---|
| committer | Daniel Baumann <mail@daniel-baumann.ch> | 2013-05-06 13:54:13 +0200 |
| commit | d7c33ee024a4c044345e9d5b79ad039c8dafd8cd (patch) | |
| tree | 5c7ba6e7dc5c038b3c9c43c4c12eb16c79b7a277 /scripts/boot/9990-overlay.sh | |
| parent | 82b09bfb04c51925877df3c5b8efaac9db6d4e5b (diff) | |
| download | live-boot-d7c33ee024a4c044345e9d5b79ad039c8dafd8cd.tar.gz live-boot-d7c33ee024a4c044345e9d5b79ad039c8dafd8cd.zip | |
Using 'local' in a safe way.
First of all, 'local' is non-POSIX, but it is a really good safeguard
against hard-to-find bugs. However, doing a local + initializing combo
like `local X=$Y` in dash is error prone. If `Y=1 2` will get an error
since dash will expand $Y so we get `local X=1 2`, but it will treat
the "2" as another variable to be made local, which isn't what we
want. Hence, let's declare variables local and initialize them in
separate commands, which is safe.
Diffstat (limited to 'scripts/boot/9990-overlay.sh')
| -rwxr-xr-x | scripts/boot/9990-overlay.sh | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/scripts/boot/9990-overlay.sh b/scripts/boot/9990-overlay.sh index 4282400..4739042 100755 --- a/scripts/boot/9990-overlay.sh +++ b/scripts/boot/9990-overlay.sh @@ -189,7 +189,8 @@ setup_unionfs () done fi - local whitelistdev="" + local whitelistdev + whitelistdev="" if [ -n "${PERSISTENCE_MEDIA}" ] then case "${PERSISTENCE_MEDIA}" in @@ -212,7 +213,8 @@ setup_unionfs () overlays="${custom_overlay_label}" fi - local overlay_devices="" + local overlay_devices + overlay_devices="" if [ "${whitelistdev}" != "ignore_all_devices" ] then for media in $(find_persistence_media "${overlays}" "${whitelistdev}") @@ -394,7 +396,8 @@ setup_unionfs () # Adding custom persistence if [ -n "${PERSISTENCE}" ] && [ -z "${NOPERSISTENCE}" ] then - local custom_mounts="/tmp/custom_mounts.list" + local custom_mounts + custom_mounts="/tmp/custom_mounts.list" rm -rf ${custom_mounts} 2> /dev/null # Gather information about custom mounts from devies detected as overlays @@ -403,7 +406,8 @@ setup_unionfs () [ -n "${DEBUG}" ] && cp ${custom_mounts} "/lib/live/mount/persistence" # Now we do the actual mounting (and symlinking) - local used_overlays="" + local used_overlays + used_overlays="" used_overlays=$(activate_custom_mounts ${custom_mounts}) rm ${custom_mounts} |
