From c55eb8a0c3ca5b8ed1081e7eb8a423563288fb58 Mon Sep 17 00:00:00 2001 From: Lyndon Brown Date: Thu, 20 Feb 2020 06:58:11 +0000 Subject: 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 --- functions/conffile.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'functions/conffile.sh') diff --git a/functions/conffile.sh b/functions/conffile.sh index 15f16c93f..ceb11ea06 100755 --- a/functions/conffile.sh +++ b/functions/conffile.sh @@ -11,10 +11,12 @@ Get_conffiles () { + local FILES if [ -n "${LB_CONFIG}" ] then FILES="${LB_CONFIG}" else + local FILE for FILE in ${@} do FILES="${FILES} ${FILE} ${FILE}.${LB_ARCHITECTURES} ${FILE}.${DISTRIBUTION}" @@ -29,6 +31,7 @@ Get_conffiles () Read_conffiles () { + local CONFFILE for CONFFILE in $(Get_conffiles "${@}") do if [ -f "${CONFFILE}" ] @@ -46,6 +49,7 @@ Read_conffiles () Print_conffiles () { + local CONFFILE for CONFFILE in $(Get_conffiles "${@}") do if [ -f "${CONFFILE}" ] -- cgit v1.2.3