Merge branch 'fix/__block/escape' into 'master'
__block: fix escaping in here-doc Closes #838 See merge request ungleich-public/cdist!962
This commit is contained in:
commit
0546d6e476
1 changed files with 10 additions and 9 deletions
|
@ -46,28 +46,29 @@ fi
|
||||||
|
|
||||||
remove_block() {
|
remove_block() {
|
||||||
cat << DONE
|
cat << DONE
|
||||||
tmpfile=\$(mktemp ${file}.cdist.XXXXXXXXXX)
|
tmpfile=\$(mktemp ${quoted_file}.cdist.XXXXXXXXXX)
|
||||||
# preserve ownership and permissions of existing file
|
# preserve ownership and permissions of existing file
|
||||||
if [ -f "$file" ]; then
|
if [ -f $quoted_file ]; then
|
||||||
cp -p "$file" "\$tmpfile"
|
cp -p $quoted_file "\$tmpfile"
|
||||||
fi
|
fi
|
||||||
awk -v prefix=^$(quote "$prefix")\$ -v suffix=^$(quote "$suffix")\$ '
|
awk -v prefix=$(quote "$prefix") -v suffix=$(quote "$suffix") '
|
||||||
{
|
{
|
||||||
if (match(\$0,prefix)) {
|
if (\$0 == prefix) {
|
||||||
triggered=1
|
triggered=1
|
||||||
}
|
}
|
||||||
if (triggered) {
|
if (triggered) {
|
||||||
if (match(\$0,suffix)) {
|
if (\$0 == suffix) {
|
||||||
triggered=0
|
triggered=0
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print
|
print
|
||||||
}
|
}
|
||||||
}' "$file" > "\$tmpfile"
|
}' $quoted_file > "\$tmpfile"
|
||||||
mv -f "\$tmpfile" "$file"
|
mv -f "\$tmpfile" $quoted_file
|
||||||
DONE
|
DONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quoted_file="$(quote "$file")"
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
present)
|
present)
|
||||||
if [ "$state_is" = "changed" ]; then
|
if [ "$state_is" = "changed" ]; then
|
||||||
|
@ -77,7 +78,7 @@ case "$state_should" in
|
||||||
echo add >> "$__messages_out"
|
echo add >> "$__messages_out"
|
||||||
fi
|
fi
|
||||||
cat << DONE
|
cat << DONE
|
||||||
cat >> "$file" << ${__type##*/}_DONE
|
cat >> $quoted_file << '${__type##*/}_DONE'
|
||||||
$(cat "$block")
|
$(cat "$block")
|
||||||
${__type##*/}_DONE
|
${__type##*/}_DONE
|
||||||
DONE
|
DONE
|
||||||
|
|
Loading…
Reference in a new issue