From 3930f69456fd5a0d108a107e4ee61d87c9a73a56 Mon Sep 17 00:00:00 2001 From: Matthias Stecher Date: Sun, 6 Dec 2020 16:45:58 +0100 Subject: [PATCH] __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 --- cdist/conf/type/__block/gencode-remote | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cdist/conf/type/__block/gencode-remote b/cdist/conf/type/__block/gencode-remote index 1f5cc033..acdb3286 100755 --- a/cdist/conf/type/__block/gencode-remote +++ b/cdist/conf/type/__block/gencode-remote @@ -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