public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Eric Lesh <eclesh@ucla•edu>
To: David Kastrup <dak@gnu•org>
Cc: git@vger•kernel.org
Subject: Re: [GUILT PATCH 2/5] guilt-guard: Assign guards to patches in series
Date: Thu, 09 Aug 2007 02:01:08 -0700	[thread overview]
Message-ID: <873aytnktn.fsf@hubert.paunchy.net> (raw)
In-Reply-To: <86r6mdp1e1.fsf@lola.quinscape.zz> (David Kastrup's message of "Thu\, 09 Aug 2007 10\:17\:58 +0200")

David Kastrup <dak@gnu•org> writes:

>>>> +	shift
>>>> +	for x in "$@"; do
>>>> +		if [ -z $(printf %s "$x" | grep -e "^[+-]") ]; then
>>>> +			echo "'$x' is not a valid guard name"
>>>> +		else
>>>> +			sed -i -e "s,^\($p[[:space:]]*.*\)$,\1 #$x," "$series"
>>>
>>> Out of curiosity, why printf and not echo?
>>>
>>
>> For guards named '-e' or other funky things echo doesn't like and
>> can't process with echo --.
>
> The problem with the above is that it reacts strangely to multiline
> options.
>

There shouldn't be multiline options passed to this function, so it
might not be a problem.

> Should be much better (and faster on shells without builtin printf) to
> use
>
> case "$x" in
>    [+-]*)
>      sed -i -e ...  ;;
>        *)
>      echo "'$x' is not ...
> esac
>
> and this runs portably without forking on shells that are 30 years
> old.  Shell script programmers _really_ should know "case" inside out.
>

Heh, as you may have noticed, I'm no shell programmer :-)  Thanks for
the advice though.

> Also, instead of 'for x in "$@"' one can just write "for x'
>

Nice.

>>> The regexp is in double quotes, so you should escape the $ (EOL),
>>> as well as all the \. Yep, this is shell scripting at its worst.
>
> \ does not need to be escaped in double quotes except before \, $ and `.
> You can write
>
>     sed -i -e "s,^\($p[[:space:]]*.*\)\$,\1 #$x," "$series"
>
> and that's fine.

Yeah.  That one made itself clear.  The sed -i needs to go too, as
Thomas observed.  The regexp itself also needs cleansing.

Lots of work to do...

	Eric

  parent reply	other threads:[~2007-08-09  9:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-31  3:11 [GUILT PATCH v2 0/5] Add guards to guilt Eric Lesh
2007-07-31  3:11 ` [GUILT PATCH 1/5] get_series: Remove comments from end of series lines Eric Lesh
2007-07-31  3:50   ` Josef Sipek
2007-07-31  3:11 ` [GUILT PATCH 2/5] guilt-guard: Assign guards to patches in series Eric Lesh
2007-07-31  4:05   ` Josef Sipek
2007-08-09  7:34     ` Eric Lesh
2007-08-09  8:17       ` David Kastrup
2007-08-09  8:22         ` Thomas Adam
2007-08-09  8:43           ` David Kastrup
2007-08-09  8:53           ` Eric Lesh
2007-08-09  9:01         ` Eric Lesh [this message]
2007-08-09 13:47       ` Josef Sipek
2007-07-31  3:11 ` [GUILT PATCH 3/5] guilt-select: Select guards to apply when pushing patches Eric Lesh
2007-07-31  3:11 ` [GUILT PATCH 4/5] get_series: return guarded patches only Eric Lesh
2007-07-31  3:11 ` [GUILT PATCH 5/5] Guards test suite Eric Lesh
2007-07-31  3:42 ` [GUILT PATCH v2 0/5] Add guards to guilt Josef Sipek

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=873aytnktn.fsf@hubert.paunchy.net \
    --to=eclesh@ucla$(echo .)edu \
    --cc=dak@gnu$(echo .)org \
    --cc=git@vger$(echo .)kernel.org \
    /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