[PATCH 3/4] ci/lib: use echo instead of printf to set up sections
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Dec 6, 2024, 11:10 UTC
- Message-ID
- <20241206-pks-ci-section-fixes-v1-3-7ab1b69e3648@pks.im>
- In-Reply-To
- <20241206-pks-ci-section-fixes-v1-0-7ab1b69e3648@pks.im>
We use printf to set up sections with GitLab CI even though we could trivially use echo. This may cause problems in case the argument passed to `begin_group ()` or `end_group ()` contains formatting directives as we use them as part of the formatting string.
Simplify the code to instead use echo.
Signed-off-by: Patrick Steinhardt <ps@pks.im> --- ci/lib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ci/lib.sh b/ci/lib.sh index a54601be923bf475ba1a9cafd98bb1cb71a10255..ba8f4da39caf29db5edaffde160bc81a7c58c329 100755 --- a/ci/lib.sh +++ b/ci/lib.sh @@ -18,7 +18,7 @@ elif test true = "$GITLAB_CI" then begin_group () { need_to_end_group=t - printf "\e[0Ksection_start:$(date +%s):$(echo "$1" | tr ' ' _)[collapsed=true]\r\e[0K$1\n" + echo "\e[0Ksection_start:$(date +%s):$(echo "$1" | tr ' ' _)[collapsed=true]\r\e[0K$1" trap "end_group '$1'" EXIT set -x } @@ -27,7 +27,7 @@ then test -n "$need_to_end_group" || return 0 set +x need_to_end_group= - printf "\e[0Ksection_end:$(date +%s):$(echo "$1" | tr ' ' _)\r\e[0K\n" + echo "\e[0Ksection_end:$(date +%s):$(echo "$1" | tr ' ' _)\r\e[0K" trap - EXIT } else
-- 2.47.0.366.g5daf58cba8.dirty