From 72ff48154c958ebdedc8b6d919b6f372efa63be2 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Thu, 16 Sep 2021 21:36:39 +0300 Subject: [PATCH] add comments, add -u to diff --- cdist/conf/type/__sed/gencode-remote | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__sed/gencode-remote b/cdist/conf/type/__sed/gencode-remote index be7690e1..f99c5a88 100755 --- a/cdist/conf/type/__sed/gencode-remote +++ b/cdist/conf/type/__sed/gencode-remote @@ -14,6 +14,8 @@ then script="$( cat "$__object/stdin" )" fi +# since stdin is not available in explorer, we pull file from target with explorer + file_from_target="$__object/explorer/file" sed_cmd='sed' @@ -23,10 +25,10 @@ then sed_cmd="$sed_cmd -E" fi -if echo "$script" \ - | "$sed_cmd" -f - "$file_from_target" \ - | diff "$file_from_target" - \ - > /dev/null +# do sed dry run, diff result and if no change, then there's nothing to do +# also redirect diff's output to stderr for debugging purposes + +if echo "$script" | "$sed_cmd" -f - "$file_from_target" | diff -u "$file_from_target" - >&2 then exit 0 fi