Re: [PATCH v2] rebase -i: respect core.commentchar

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 12, 2013 at 09:29:26AM -0800, Junio C Hamano wrote:
> John Keeping <john@xxxxxxxxxxxxx> writes:
> 
> > ... the following fixup is also needed to avoid relying on the shell
> > emitting a literal backslash when a backslash isn't followed by a known
> > escape character.
> >
> > -- >8 --
> >
> > diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
> > index cbe36bf..84bd525 100755
> > --- a/t/t3404-rebase-interactive.sh
> > +++ b/t/t3404-rebase-interactive.sh
> > @@ -947,7 +947,7 @@ test_expect_success 'rebase -i respects core.commentchar' '
> >  	test_when_finished "git config --unset core.commentchar" &&
> >  	cat >comment-lines.sh <<EOF &&
> >  #!$SHELL_PATH
> > -sed -e "2,\$ s/^/\\\\\\/" "\$1" >"\$1".tmp
> > +sed -e "2,\$ s/^/\\\\\\\\/" "\$1" >"\$1".tmp
> >  mv "\$1".tmp "\$1"
> >  EOF
> >  	chmod a+x comment-lines.sh &&
> 
> Yeek.  If you used write_script with here-text that does not
> interpolate,
> 
> 	write_script remove-all-but-the-first.sh <<\EOF
> 	sed -e '2,$s/^/\\/'  <"$1" >"$1.tmp" &&
>         mv "$1.tmp" "$1"
> 	EOF
> 
> the above would be much more readable.

Yet another thing for me to learn about ;-)

Do you mean to use that outside the test case, so that the single quotes
work?  Or do I still need some level of escaping?

> I am not sure if I understand what you meant by "literal backslash
> blah blah", though.

It turns out that having this in the script works (in bash and dash
although I haven't checked what Posix has to say about it):

    sed -e "2,$ s/^/\\\/"

and is equivalent to:

    sed -e '2,$ s/^/\\/'

because backslashes that aren't recognised as part of an escape sequence
are not treated specially.


John
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]