Re: [GUILT PATCH 2/5] guilt-guard: Assign guards to patches in series
- From
- Eric Lesh <eclesh@ucla.edu>
- Date
- Aug 9, 2007, 09:01 UTC
- Message-ID
- <873aytnktn.fsf@hubert.paunchy.net>
- In-Reply-To
- <86r6mdp1e1.fsf@lola.quinscape.zz>
David Kastrup <dak@gnu.org> writes:
Show 16 quoted lines
>>>> + 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.
Show 13 quoted lines
> 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.
Show 9 quoted lines
>>> 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