Skip to content

Commit

Permalink
fix: bash_replace_or_append: use bash_ensure_nl_at_eof
Browse files Browse the repository at this point in the history
Moved jinja whitespace trim from end to start as it works best that way.
  • Loading branch information
maage committed May 17, 2023
1 parent 268b260 commit 3863e94
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions shared/macros/10-bash.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3863e94

Please sign in to comment.