From d7c33ee024a4c044345e9d5b79ad039c8dafd8cd Mon Sep 17 00:00:00 2001 From: Tails developers Date: Fri, 7 Dec 2012 22:31:36 +0100 Subject: 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. --- scripts/boot/9990-mount-http.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'scripts/boot/9990-mount-http.sh') 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 -- cgit v1.2.3