__block: fix escaping in here-doc

This changes the here-document to do not interpret any shell-things. It
also single-quotes some more strings that are printed to code-remote.

Fixes #838
This commit is contained in:
matze 2020-12-06 16:45:58 +01:00
parent 23e0da521c
commit 3930f69456

View file

@ -46,10 +46,10 @@ fi
remove_block() {
cat << DONE
tmpfile=\$(mktemp ${file}.cdist.XXXXXXXXXX)
tmpfile=\$(mktemp '${file}.cdist.XXXXXXXXXX')
# preserve ownership and permissions of existing file
if [ -f "$file" ]; then
cp -p "$file" "\$tmpfile"
if [ -f '$file' ]; then
cp -p '$file' "\$tmpfile"
fi
awk -v prefix=^$(quote "$prefix")\$ -v suffix=^$(quote "$suffix")\$ '
{
@ -63,8 +63,8 @@ awk -v prefix=^$(quote "$prefix")\$ -v suffix=^$(quote "$suffix")\$ '
} else {
print
}
}' "$file" > "\$tmpfile"
mv -f "\$tmpfile" "$file"
}' '$file' > "\$tmpfile"
mv -f "\$tmpfile" '$file'
DONE
}
@ -77,7 +77,7 @@ case "$state_should" in
echo add >> "$__messages_out"
fi
cat << DONE
cat >> "$file" << ${__type##*/}_DONE
cat >> '$file' << '${__type##*/}_DONE'
$(cat "$block")
${__type##*/}_DONE
DONE