git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [GUILT PATCH 2/5] guilt-guard: Assign guards to patches in series

From
ELEric 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
Previous: Eric LeshNext: Josef Sipek
Message 11 of 16 in “Add guards to guilt”
  1. 0/5 Add guards to guiltEric Lesh, Jul 31, 2007
  2. 1/5 get_series: Remove comments from end of series linesEric Lesh, Jul 31, 2007
  3. Josef SipekJul 31, 2007
  4. 2/5 guilt-guard: Assign guards to patches in seriesEric Lesh, Jul 31, 2007
  5. Josef SipekJul 31, 2007
  6. Eric LeshAug 9, 2007
  7. David KastrupAug 9, 2007
  8. Thomas AdamAug 9, 2007
  9. David KastrupAug 9, 2007
  10. Eric LeshAug 9, 2007
  11. Eric LeshAug 9, 2007
  12. Josef SipekAug 9, 2007
  13. 3/5 guilt-select: Select guards to apply when pushing patchesEric Lesh, Jul 31, 2007
  14. 4/5 get_series: return guarded patches onlyEric Lesh, Jul 31, 2007
  15. 5/5 Guards test suiteEric Lesh, Jul 31, 2007
  16. Josef SipekJul 31, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.