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-mount-http.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-mount-http.sh')
| -rwxr-xr-x | scripts/boot/9990-mount-http.sh | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/scripts/boot/9990-mount-http.sh b/scripts/boot/9990-mount-http.sh index 1b718c0..b557404 100755 --- a/scripts/boot/9990-mount-http.sh +++ b/scripts/boot/9990-mount-http.sh @@ -8,8 +8,9 @@ do_httpmount () for webfile in HTTPFS FTPFS FETCH do - local url="$(eval echo \"\$\{${webfile}\}\")" - local extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')" + local url extension dest + url="$(eval echo \"\$\{${webfile}\}\")" + extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')" if [ -n "$url" ] then @@ -20,7 +21,7 @@ do_httpmount () mkdir -p "${alt_mountpoint}" dest="${alt_mountpoint}" else - local dest="${mountpoint}/${LIVE_MEDIA_PATH}" + dest="${mountpoint}/${LIVE_MEDIA_PATH}" mount -t ramfs ram "${mountpoint}" mkdir -p "${dest}" fi |
