From 3863e94f811d90c79c8d4968e731ac42e90f5ac5 Mon Sep 17 00:00:00 2001 From: Markus Linnala Date: Tue, 16 May 2023 13:19:51 +0300 Subject: [PATCH] fix: bash_replace_or_append: use bash_ensure_nl_at_eof Moved jinja whitespace trim from end to start as it works best that way. --- shared/macros/10-bash.jinja | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shared/macros/10-bash.jinja b/shared/macros/10-bash.jinja index 2082b5316fcb..59ec04a48cba 100644 --- a/shared/macros/10-bash.jinja +++ b/shared/macros/10-bash.jinja @@ -1529,10 +1529,10 @@ if LC_ALL=C grep -q -m 1 -i -e "{{{ key }}}\\>" "{{{ config_file }}}"; then escaped_formatted_output=$(sed -e 's|/|\\/|g' <<< "$formatted_output") "${sed_command[@]}" "s/{{{ key }}}\\>.*/$escaped_formatted_output/gi" "{{{ config_file }}}" else - # \n is precaution for case where file ends without trailing newline - {{% if cce_identifiers and 'cce' in cce_identifiers -%}} + {{{ bash_ensure_nl_at_eof(config_file) | indent }}} + {{%- if cce_identifiers and 'cce' in cce_identifiers %}} {{{ set_cce_value() }}} - printf '\n# Per %s: Set %s in %s\n' "$cce" "$formatted_output" "{{{ config_file }}}" >> "{{{ config_file }}}" + printf '# Per %s: Set %s in %s\n' "${cce}" "${formatted_output}" "{{{ config_file }}}" >> "{{{ config_file }}}" {{%- endif %}} printf '%s\n' "$formatted_output" >> "{{{ config_file }}}" fi