use while read -> avoids ifs problem

Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
Nico Schottelius 2014-02-24 18:06:15 +01:00
parent ce0f779664
commit a126bd955f
1 changed files with 6 additions and 10 deletions

View File

@ -71,21 +71,17 @@ _cksum() {
echo "$1" | cksum | cut -d' ' -f 1
}
# Add each key
IFS=$'\n'
for key in $(cat "$__object/parameter/key"); do
unset IFS
raw_key="$(echo "$key" | tr ' ' '\n' | awk '/^ssh-(rsa|dsa)/ {printf $1" ";getline;printf $1}')"
cksum_key="$(_cksum "$raw_key")"
while read key; do
cksum_key="$(_cksum "$key")"
line_id="${owner}-${cksum_key}"
set -- "$line_id"
set -- "$@" --file "$file"
set -- "$@" --regex ".*$raw_key.*"
set -- "$@" --regex ".*$key.*"
if [ "$state" = 'present' ]; then
set -- "$@" --line "$key"
fi
set -- "$@" --state "$state"
require="__block/$__object_name" __line "$@"
done
# Ensure __line does not read stdin
require="__block/$__object_name" __line "$@" < /dev/null
done < "$__object/parameter/key"