diff options
| author | Lyndon Brown <jnqnfe@gmail.com> | 2020-02-20 06:58:11 +0000 |
|---|---|---|
| committer | Lyndon Brown <jnqnfe@gmail.com> | 2020-03-16 22:10:03 +0000 |
| commit | c55eb8a0c3ca5b8ed1081e7eb8a423563288fb58 (patch) | |
| tree | 6ea61f7291b27ce9e22b40c5593c6ab6f54555d2 /functions/packagelists.sh | |
| parent | af040d78035b88aaf2f99f38bf5f0db176c92d0a (diff) | |
| download | vyos-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/packagelists.sh')
| -rwxr-xr-x | functions/packagelists.sh | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/functions/packagelists.sh b/functions/packagelists.sh index 4701c3c70..ad31f4909 100755 --- a/functions/packagelists.sh +++ b/functions/packagelists.sh @@ -11,17 +11,20 @@ Expand_packagelist () { + local _LB_EXPAND_QUEUE _LB_EXPAND_QUEUE="$(basename "${1}")" shift while [ -n "${_LB_EXPAND_QUEUE}" ] do + local _LB_LIST_NAME + local _LB_EXPAND_QUEUE _LB_LIST_NAME="$(echo ${_LB_EXPAND_QUEUE} | cut -d" " -f1)" _LB_EXPAND_QUEUE="$(echo ${_LB_EXPAND_QUEUE} | cut -s -d" " -f2-)" - _LB_LIST_LOCATION="" - _LB_NESTED=0 - _LB_ENABLED=1 + local _LB_LIST_LOCATION="" + local _LB_NESTED=0 + local _LB_ENABLED=1 for _LB_SEARCH_PATH in ${@} do @@ -42,6 +45,7 @@ Expand_packagelist () do case "${_LB_LINE}" in \!*) + local _EXEC _EXEC="$(echo ${_LB_LINE} | sed -e 's|^!||')" case "${LB_BUILD_WITH_CHROOT}" in @@ -63,6 +67,10 @@ Expand_packagelist () fi _LB_NESTED=1 + local _LB_NEEDLE + local _LB_HAYSTACK + local _LB_NEEDLE_PART + local _LB_HAYSTACK_PART _LB_NEEDLE="$(echo "${_LB_LINE}" | cut -d' ' -f3-)" _LB_HAYSTACK="$(eval "echo \$LB_$(echo "${_LB_LINE}" | cut -d' ' -f2)")" @@ -87,6 +95,10 @@ Expand_packagelist () fi _LB_NESTED=1 + local _LB_NEEDLE + local _LB_HAYSTACK + local _LB_NEEDLE_PART + local _LB_HAYSTACK_PART _LB_NEEDLE="$(echo "${_LB_LINE}" | cut -d' ' -f3-)" _LB_HAYSTACK="$(eval "echo \$LB_$(echo "${_LB_LINE}" | cut -d' ' -f2)")" @@ -126,13 +138,15 @@ Expand_packagelist () Discover_package_architectures () { - _LB_EXPANDED_PKG_LIST="${1}" - _LB_DISCOVERED_ARCHITECTURES="" + local _LB_EXPANDED_PKG_LIST="${1}" + local _LB_DISCOVERED_ARCHITECTURES="" shift if [ -e "${_LB_EXPANDED_PKG_LIST}" ] && [ -s "${_LB_EXPANDED_PKG_LIST}" ] then + local _LB_PACKAGE_LINE + local _LB_PACKAGE_LINE_PART while read _LB_PACKAGE_LINE do # Lines from the expanded package list may have multiple, space-separated packages |
