From: Junio C Hamano Date: Tue, 12 Feb 2013 18:21:57 GMT Subject: Re: [PATCH v2] rebase -i: respect core.commentchar Message-ID: <7vip5xgzp6.fsf@alter.siamese.dyndns.org> In-Reply-To: <20130212175322.GC13501@farnsworth.metanate.com> John Keeping writes: >> 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. That's POSIX. Inside a dq pair: \ The shall retain its special meaning as an escape character (see Escape Character (Backslash)) only when followed by one of the following characters when considered special: $ ` " \ So in your example "\\\/", the first backslash escapes the second backslash and together they produce a single backslash, the third backslash is followed by a slash that is not special at all, so it produces a second backslash, and the slash stands for itself, resulting in "\\/".