summaryrefslogtreecommitdiff
path: root/functions/cache.sh
diff options
context:
space:
mode:
authorLyndon Brown <jnqnfe@gmail.com>2020-02-20 06:58:11 +0000
committerLyndon Brown <jnqnfe@gmail.com>2020-03-16 22:10:03 +0000
commitc55eb8a0c3ca5b8ed1081e7eb8a423563288fb58 (patch)
tree6ea61f7291b27ce9e22b40c5593c6ab6f54555d2 /functions/cache.sh
parentaf040d78035b88aaf2f99f38bf5f0db176c92d0a (diff)
downloadvyos-live-build-c55eb8a0c3ca5b8ed1081e7eb8a423563288fb58.tar.gz
vyos-live-build-c55eb8a0c3ca5b8ed1081e7eb8a423563288fb58.zip
use local scope for private function vars
all vars affected have been carefully checked to be quite certain that they are definitely local where variable is assigned the return value of a function/command, the local "declaration" is deliberately done on a separate line, since `local FOO` is actually treated itself as a command rather than a declaration; will thus always cause $? to be zero, and thus if done on the same line as such an assignment can not only clobber $? but in doing so unintentionally blocks failure of a command from triggering the expected exit from having `set -e`. also, from testing, i have found that when assigning "${@}" this must be done on a separate line confusingly as otherwise an error occurs. Gbp-Dch: Short
Diffstat (limited to 'functions/cache.sh')
-rwxr-xr-xfunctions/cache.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/functions/cache.sh b/functions/cache.sh
index 4e4c4b884..3e5c7ef70 100755
--- a/functions/cache.sh
+++ b/functions/cache.sh
@@ -11,7 +11,7 @@
Restore_package_cache ()
{
- DIRECTORY="cache/packages.${1}"
+ local DIRECTORY="cache/packages.${1}"
if [ "${LB_CACHE}" = "true" ] && [ "${LB_CACHE_PACKAGES}" = "true" ]
then
@@ -32,7 +32,7 @@ Restore_package_cache ()
Save_package_cache ()
{
- DIRECTORY="cache/packages.${1}"
+ local DIRECTORY="cache/packages.${1}"
if [ "${LB_CACHE}" = "true" ] && [ "${LB_CACHE_PACKAGES}" = "true" ]
then
@@ -47,6 +47,7 @@ Save_package_cache ()
mkdir -p "${DIRECTORY}"
# Saving new cache
+ local PACKAGE
for PACKAGE in chroot/var/cache/apt/archives/*.deb
do
if [ -e "${DIRECTORY}"/"$(basename ${PACKAGE})" ]