Re: [RFC/PATCH 1/4] Add git-sequencer shell prototype
- From
Stephan Beyer <s-beyer@gmx.net>
- Date
- Jul 3, 2008, 23:33 UTC
- Message-ID
- <20080703233343.GF6677@leksak.fem-net>
- In-Reply-To
- <7vlk0iy5we.fsf@gitster.siamese.dyndns.org>
Hi again,
On Thu, Jul 03, 2008 at 03:11:45PM -0700, Junio C Hamano wrote:
Show 10 quoted lines
> Stephan Beyer <s-beyer@gmx.net> writes: > > + sed -e 's/[$"\\]/\\&/g' -n -e ' > > s/^Author: \(.*\)$/GIT_AUTHOR_NAME="\1"/p; > > s/^Email: \(.*\)$/GIT_AUTHOR_EMAIL="\1"/p; > > s/^Date: \(.*\)$/GIT_AUTHOR_DATE="\1"/p > > ### > > > > Is escaping $, " and \ enough? > > Look at how it is done in git-sh-setup get_author_ident_from_commit.
Yes, single quotes are the other variant and perhaps a little more robust.
--- a/git-sequencer.sh +++ b/git-sequencer.sh @@ -520,8 +520,9 @@ clean_author_script () { # Take "Name <e-mail>" in stdin and outputs author script make_author_script_from_string () { - sed -e 's/^\(.*\) <\(.*\)>.*$/GIT_AUTHOR_NAME="\1"\ -GIT_AUTHOR_EMAIL="\2"\ + sed -e "s/'/'"'\\'"''/g" \ + -e 's/^\(.*\) <\(.*\)>.*$/GIT_AUTHOR_NAME='\''\1'\''\ +GIT_AUTHOR_EMAIL='\''\2'\''\ GIT_AUTHOR_DATE=/' } @@ -779,10 +780,10 @@ insn_patch () { if test -z "$AUTHOR" then - sed -n -e ' - s/^Author: \(.*\)$/GIT_AUTHOR_NAME="\1"/p; - s/^Email: \(.*\)$/GIT_AUTHOR_EMAIL="\1"/p; - s/^Date: \(.*\)$/GIT_AUTHOR_DATE="\1"/p + sed -e "s/'/'"'\\'"''/g" -n -e ' + s/^Author: \(.*\)$/GIT_AUTHOR_NAME='\''\1'\''/p; + s/^Email: \(.*\)$/GIT_AUTHOR_EMAIL='\''\1'\''/p; + s/^Date: \(.*\)$/GIT_AUTHOR_DATE='\''\1'\''/p ' <"$infofile" >>"$AUTHOR_SCRIPT" # If sed's result is empty, we keep the original # author script by appending. ### On Thu, Jul 03, 2008 at 11:09:50PM +0200, Stephan Beyer wrote: > And as long as nobody is named $(rm -rf "$HOME") [1], I thought this is > sufficient for the prototype. Btw, the [1] should have been a link to http://xkcd.com/327/ Just if you're wondering ;-) Regards, Stephan
-- Stephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F