public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks•im>
To: Toon Claes <toon@iotcl•com>
Cc: git@vger•kernel.org,
	Oswald Buddenhagen <oswald.buddenhagen@gmx•de>,
	karthik nayak <karthik.188@gmail•com>
Subject: Re: [PATCH v2 3/4] ci/lib: do not interpret escape sequences in `group ()` arguments
Date: Thu, 12 Dec 2024 07:47:41 +0100	[thread overview]
Message-ID: <Z1qGmp4NC21XYC4a@pks.im> (raw)
In-Reply-To: <874j3ajsym.fsf@iotcl.com>

On Wed, Dec 11, 2024 at 01:37:53PM +0100, Toon Claes wrote:
> Patrick Steinhardt <ps@pks•im> writes:
> 
> > We use printf to set up sections with GitLab CI, which requires us to
> > print a bunch of escape sequences via printf. The group name is
> > controlled by the user and is expanded directly into the formatting
> > string, which may cause problems in case the argument controls escape
> > sequences or formatting directives.
> 
> Could it be you mean "contains" instead of "controls"?

Oh, yeah.

> > Fix this potential issue by using formatting directives to pass variable
> > data.
> >
> > 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..f15f77f03a06120afbee438cee76ddc2683e1fa2 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"
> > +		printf '\e[0Ksection_start:%s:%s[collapsed=true]\r\e[0K%s\n' "$(date +%s)" "$(echo "$1" | tr ' ' _)" "$1"
> 
> Personally I find this line rather lengthy and hard to read with all the
> single and double quotes. So I would suggest to split the line with a
> backslash and put the arguments on a separate line. But I don't think
> there's a general guideline on this, so feel free to ignore.

Fair, will do.

> >  		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"
> > +		printf '\e[0Ksection_end:%s:%s\r\e[0K\n' "$(date +%s)" "$(echo "$1" | tr ' ' _)"
> 
> Same here.
> 
> But that's all I've got on this patch series. Looking good!

Thanks!

Patrick

  reply	other threads:[~2024-12-12  6:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-06 11:10 [PATCH 0/4] Random improvements to GitLab CI Patrick Steinhardt
2024-12-06 11:10 ` [PATCH 1/4] gitlab-ci: update macOS images to Sonoma Patrick Steinhardt
2024-12-06 11:39   ` karthik nayak
2024-12-06 12:02     ` Patrick Steinhardt
2024-12-07  9:49       ` karthik nayak
2024-12-06 11:10 ` [PATCH 2/4] ci/lib: remove duplicate trap to end "CI setup" group Patrick Steinhardt
2024-12-06 11:10 ` [PATCH 3/4] ci/lib: use echo instead of printf to set up sections Patrick Steinhardt
2024-12-07  9:13   ` Oswald Buddenhagen
2024-12-10 11:56     ` Patrick Steinhardt
2024-12-06 11:10 ` [PATCH 4/4] ci/lib: fix "CI setup" sections with GitLab CI Patrick Steinhardt
2024-12-06 11:46   ` karthik nayak
2024-12-06 11:47 ` [PATCH 0/4] Random improvements to " karthik nayak
2024-12-06 12:02   ` Patrick Steinhardt
2024-12-10 12:01 ` [PATCH v2 " Patrick Steinhardt
2024-12-10 12:01   ` [PATCH v2 1/4] gitlab-ci: update macOS images to Sonoma Patrick Steinhardt
2024-12-10 12:01   ` [PATCH v2 2/4] ci/lib: remove duplicate trap to end "CI setup" group Patrick Steinhardt
2024-12-10 12:01   ` [PATCH v2 3/4] ci/lib: do not interpret escape sequences in `group ()` arguments Patrick Steinhardt
2024-12-11 12:37     ` Toon Claes
2024-12-12  6:47       ` Patrick Steinhardt [this message]
2024-12-10 12:01   ` [PATCH v2 4/4] ci/lib: fix "CI setup" sections with GitLab CI Patrick Steinhardt
2024-12-12  6:47 ` [PATCH v3 0/4] Random improvements to " Patrick Steinhardt
2024-12-12  6:47   ` [PATCH v3 1/4] gitlab-ci: update macOS images to Sonoma Patrick Steinhardt
2024-12-12  6:47   ` [PATCH v3 2/4] ci/lib: remove duplicate trap to end "CI setup" group Patrick Steinhardt
2024-12-12  6:47   ` [PATCH v3 3/4] ci/lib: do not interpret escape sequences in `group ()` arguments Patrick Steinhardt
2024-12-12  6:47   ` [PATCH v3 4/4] ci/lib: fix "CI setup" sections with GitLab CI Patrick Steinhardt
2024-12-12 11:57   ` [PATCH v3 0/4] Random improvements to " Toon Claes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z1qGmp4NC21XYC4a@pks.im \
    --to=ps@pks$(echo .)im \
    --cc=git@vger$(echo .)kernel.org \
    --cc=karthik.188@gmail$(echo .)com \
    --cc=oswald.buddenhagen@gmx$(echo .)de \
    --cc=toon@iotcl$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox