summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-05-24 00:25:17 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-05-24 00:25:17 -0400
commit5b417dd20f576ce36fe9150f03b16aeca1bfbf95 (patch)
tree9eedcd8dfd894290a1ee9794a9fd89e86d9be066 /src
parent8659451622a94dad8a5446b223e6bbafb021f693 (diff)
lib/conf.sh: Tidy loops
use while read -r var; do ... done < <(...) rather than for var in $(...); do ... done
Diffstat (limited to 'src')
-rw-r--r--src/lib/conf.sh.in16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/conf.sh.in b/src/lib/conf.sh.in
index 1e4acd9..18760e1 100644
--- a/src/lib/conf.sh.in
+++ b/src/lib/conf.sh.in
@@ -112,21 +112,21 @@ load_files() {
local file
# Save the existing versions at _VARNAME
- for var in $(list_envvars "$slug"); do
+ while read -r var; do
[[ -n ${!var:-} ]] && eval "_$var=\${$var}"
- done
+ done < <(list_envvars "$slug")
# Load the files
- for file in $(list_files "$slug"); do
+ while read -r file; do
if [[ -r $file ]]; then
. "$file" || return 1
fi
- done
+ done < <(list_files "$slug")
# Restore the _SAVED versions
- for var in $(list_envvars "$slug"); do
+ while read -r var; do
eval "$var=\${_$var:-\${$var:-}}"
- done
+ done < <(list_envvars "$slug")
}
# Usage: check_vars $slug VAR1 VAR2...
@@ -174,13 +174,13 @@ set_var() {
local key=$2
local val=$3
local file
- for file in $(list_files "$slug"|tac); do
+ while read -r file; do
if [[ -w $file ]]; then
sed -i "/^\s*$key=/d" "$file"
printf '%s=%q\n' "$key" "$val" >> "$file"
return 0
fi
- done
+ done < <(list_files "$slug"|tac)
return 1
}