From 1b49b58677dfc85ca2f586ca573babef1c5a1c8a Mon Sep 17 00:00:00 2001 From: Denys Holius <5650611+denisgolius@users.noreply.github.com> Date: Tue, 4 Jul 2023 12:38:39 +0300 Subject: [PATCH] docs: use printf for Makefile:copy-docs section (#4548) printf handles new line char for cross-platform use --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0d50b29b8..a5d1c2393 100644 --- a/Makefile +++ b/Makefile @@ -478,16 +478,18 @@ check-licenses: install-wwhrd wwhrd check -f .wwhrd.yml copy-docs: +# The 'printf' function is used instead of 'echo' or 'echo -e' to handle line breaks (e.g. '\n') in the same way on different operating systems (MacOS/Ubuntu Linux/Arch Linux) and their shells (bash/sh/zsh/fish). +# For details, see https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4548#issue-1782796419 and https://stackoverflow.com/questions/8467424/echo-newline-in-bash-prints-literal-n echo "---" > ${DST} @if [ ${ORDER} -ne 0 ]; then \ echo "sort: ${ORDER}" >> ${DST}; \ echo "weight: ${ORDER}" >> ${DST}; \ - echo "menu:\n docs:\n parent: 'victoriametrics'\n weight: ${ORDER}" >> ${DST}; \ + printf "menu:\n docs:\n parent: 'victoriametrics'\n weight: ${ORDER}\n" >> ${DST}; \ fi echo "title: ${TITLE}" >> ${DST} @if [ ${OLD_URL} ]; then \ - echo "aliases:\n - ${OLD_URL}" >> ${DST}; \ + printf "aliases:\n - ${OLD_URL}\n" >> ${DST}; \ fi echo "---" >> ${DST} cat ${SRC} >> ${DST}