# Escape character for .gitconfig

9 messages from 2011-12-17 to 2011-12-21. Participants: Erik Blake, Jeff King, Dirk Süsserott, Peter Krefting, demerphq.
Thread: https://gitlist.dev/t/29196

## Erik Blake, 2011-12-17 10:10

Subject: Escape character for .gitconfig
Message-ID: <4EEC6A9D.1060005@icefield.yk.ca>
URL: https://gitlist.dev/e/4EEC6A9D.1060005%40icefield.yk.ca

```
I have an editor path that includes "(" and ")". No matter how I try to 
escape this character, I get either variations on:

C:/Program Files (x86)/Notepad++/notepad++.exe: -c: line 0: syntax error 
near unexpected token `('
C:/Program Files (x86)/Notepad++/notepad++.exe: -c: line 0: `C:/Program 
Files (x86)/Notepad++/notepad++.exe \$@\'
error: There was a problem with the editor 'C:/Program Files 
(x86)/Notepad++/notepad++.exe'.
Please supply the message using either -m or -F option.

or:

fatal: bad config file line 5 in C:\Users\xxx/.gitconfig

As you can see, I'm running git on a Win7 64 machine. Is there any way 
to escape the brackets? Or do I need to reinstall notepad++ on a 
different path?

```

## Jeff King, 2011-12-17 10:58

Subject: Re: Escape character for .gitconfig
Message-ID: <20111217105806.GB23935@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20111217105806.GB23935%40sigill.intra.peff.net
In-Reply-To: <4EEC6A9D.1060005@icefield.yk.ca>

```
On Sat, Dec 17, 2011 at 11:10:37AM +0100, Erik Blake wrote:

> I have an editor path that includes "(" and ")". No matter how I try
> to escape this character, I get either variations on:
> 
> C:/Program Files (x86)/Notepad++/notepad++.exe: -c: line 0: syntax
> error near unexpected token `('
> C:/Program Files (x86)/Notepad++/notepad++.exe: -c: line 0:
> `C:/Program Files (x86)/Notepad++/notepad++.exe \$@\'
> error: There was a problem with the editor 'C:/Program Files
> (x86)/Notepad++/notepad++.exe'.
> Please supply the message using either -m or -F option.
> 
> or:
> 
> fatal: bad config file line 5 in C:\Users\xxx/.gitconfig

You didn't tell us what you actually tried, so I don't know where you
went wrong.

But you will need to quote the whole value for git to read from your
gitconfig, and then quote any metacharacters in the value so that the
shell doesn't interpret them. I think you want:

  [core]
    editor = "'C:/Program Files (x86)/Notepad++/notepad++.exe'"

-Peff

```

## Erik Blake, 2011-12-18 07:53

Subject: Re: Escape character for .gitconfig
Message-ID: <4EED9BE5.8060600@icefield.yk.ca>
URL: https://gitlist.dev/e/4EED9BE5.8060600%40icefield.yk.ca
In-Reply-To: <20111217105806.GB23935@sigill.intra.peff.net>

```
Thanks Jeff,
That did the trick for this git newb. For the record, I had tried \(, 
/(, double- and single-quoting the entire path (note that git config 
--global had removed the quotes that were originally around the string). 
Did not think of "nested" quotes.

Now, however, I have a different problem in that notepad++ is somehow 
signalling git that editing is complete before I even get a chance to 
edit the file. I am trying the command
 >git commit --amend

Notepad++ opens with the message, but git completes the commit before I 
get a chance to make any changes. I suspect the issue is that git fires 
up a new instance of notepad++ (which in my case is already running with 
some other files open). notepad++ sees the new instance starting and 
subsumes it under the pre-existing instance and then closes the new 
instance. git sees the task close and assumes I am done editing.

Oh well. Cannot use notepad.exe because it does not handle <lf> line 
endings. I guess I'll stick to the git gui.

e.

On 2011-12-17 11:58, Jeff King wrote:
> On Sat, Dec 17, 2011 at 11:10:37AM +0100, Erik Blake wrote:
>
>> I have an editor path that includes "(" and ")". No matter how I try
>> to escape this character, I get either variations on:
>>
>> C:/Program Files (x86)/Notepad++/notepad++.exe: -c: line 0: syntax
>> error near unexpected token `('
>> C:/Program Files (x86)/Notepad++/notepad++.exe: -c: line 0:
>> `C:/Program Files (x86)/Notepad++/notepad++.exe \$@\'
>> error: There was a problem with the editor 'C:/Program Files
>> (x86)/Notepad++/notepad++.exe'.
>> Please supply the message using either -m or -F option.
>>
>> or:
>>
>> fatal: bad config file line 5 in C:\Users\xxx/.gitconfig
>
> You didn't tell us what you actually tried, so I don't know where you
> went wrong.
>
> But you will need to quote the whole value for git to read from your
> gitconfig, and then quote any metacharacters in the value so that the
> shell doesn't interpret them. I think you want:
>
>    [core]
>      editor = "'C:/Program Files (x86)/Notepad++/notepad++.exe'"
>
> -Peff

```

## Jeff King, 2011-12-18 09:51

Subject: Re: Escape character for .gitconfig
Message-ID: <20111218095120.GA2290@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20111218095120.GA2290%40sigill.intra.peff.net
In-Reply-To: <4EED9BE5.8060600@icefield.yk.ca>

```
On Sun, Dec 18, 2011 at 08:53:09AM +0100, Erik Blake wrote:

> That did the trick for this git newb. For the record, I had tried \(,
> /(, double- and single-quoting the entire path (note that git config
> --global had removed the quotes that were originally around the
> string). Did not think of "nested" quotes.

Yeah, if you are using "git config" to enter it on the command line,
you'll have to put an extra layer of quoting around it to pass it
through the shell you're currently running. That's why I showed the
example as the actual config file text. :)

> Now, however, I have a different problem in that notepad++ is somehow
> signalling git that editing is complete before I even get a chance to
> edit the file. I am trying the command
> >git commit --amend

Yep. This is a general problem with editors that open files in an
existing session. The only signal git has of the user being done editing
is when when the editor process exits. For many editors, there is an
option or other trick for sticking around until the file is closed.

I know nothing about notepad++, but a quick google turned up the
"-multiInst" option, which would avoid attaching to the existing
instance. That might work for you.

-Peff

```

## Dirk Süsserott, 2011-12-19 15:59

Subject: Re: Escape character for .gitconfig
Message-ID: <4EEF5F59.8030802@dirk.my1.cc>
URL: https://gitlist.dev/e/4EEF5F59.8030802%40dirk.my1.cc
In-Reply-To: <20111218095120.GA2290@sigill.intra.peff.net>

```
Am 18.12.2011 10:51 schrieb Jeff King:
> On Sun, Dec 18, 2011 at 08:53:09AM +0100, Erik Blake wrote:
> 
[...]
>> Now, however, I have a different problem in that notepad++ is somehow
>> signalling git that editing is complete before I even get a chance to
>> edit the file. I am trying the command
>>> git commit --amend
[...]
> 
> I know nothing about notepad++, but a quick google turned up the
> "-multiInst" option, which would avoid attaching to the existing
> instance. That might work for you.
> 
> -Peff

Jeff is right! I also use notepad++ and have set

export GIT_EDITOR='notepad++ -multiInst'

in my .bashrc (msysGit). And btw: notepad++ DOES handle cr/lf. Look at
the "Format" menu.

    Dirk

```

## Erik Blake, 2011-12-20 08:04

Subject: Re: Escape character for .gitconfig
Message-ID: <4EF04199.1010008@icefield.yk.ca>
URL: https://gitlist.dev/e/4EF04199.1010008%40icefield.yk.ca
In-Reply-To: <4EEF5F59.8030802@dirk.my1.cc>

```
Hi Dirk,

I ended up using "'C:/Program Files (x86)/Notepad++/notepad++.exe' 
-multiInst -notabbar -nosession -noPlugin" which works nicely for me 
(note the placement of the inner quotations).

It is notepad.exe (the default Windows editor) that fails on files with 
only <lf> termination. That's why I was trying to set notepad++ as the 
git editor as it is vastly superior.

Cheers,
Erik

On 2011-12-19 16:59, Dirk Süsserott wrote:
> Am 18.12.2011 10:51 schrieb Jeff King:
>> On Sun, Dec 18, 2011 at 08:53:09AM +0100, Erik Blake wrote:
>>
> [...]
>>> Now, however, I have a different problem in that notepad++ is somehow
>>> signalling git that editing is complete before I even get a chance to
>>> edit the file. I am trying the command
>>>> git commit --amend
> [...]
>> I know nothing about notepad++, but a quick google turned up the
>> "-multiInst" option, which would avoid attaching to the existing
>> instance. That might work for you.
>>
>> -Peff
> Jeff is right! I also use notepad++ and have set
>
> export GIT_EDITOR='notepad++ -multiInst'
>
> in my .bashrc (msysGit). And btw: notepad++ DOES handle cr/lf. Look at
> the "Format" menu.
>
>      Dirk

```

## Dirk Süsserott, 2011-12-20 19:46

Subject: Re: Escape character for .gitconfig
Message-ID: <4EF0E624.1090500@dirk.my1.cc>
URL: https://gitlist.dev/e/4EF0E624.1090500%40dirk.my1.cc
In-Reply-To: <4EF04199.1010008@icefield.yk.ca>

```
Am 20.12.2011 09:04 schrieb Erik Blake:
> Hi Dirk,
>
> I ended up using "'C:/Program Files (x86)/Notepad++/notepad++.exe'
> -multiInst -notabbar -nosession -noPlugin" which works nicely for me
> (note the placement of the inner quotations).
>
> It is notepad.exe (the default Windows editor) that fails on files with
> only <lf> termination. That's why I was trying to set notepad++ as the
> git editor as it is vastly superior.
>
> Cheers,
> Erik

Hi Erik,

oops, I overread that you talked about notepad (not notepad++) and the
<lf> stuff. My fault. I use the portable version of notepad++ and don't
have the "space in path" problem. But if you mainly use the git-bash (as
I do) instead of cmd.exe, then probably you could tweak your .bashrc:

export PATH="/C:/Program Files (x86)/Notepad++":$PATH

and then run notepad++ w/o giving the absolute path.

Cheers,
    Dirk

```

## Peter Krefting, 2011-12-21 12:54

Subject: Re: Escape character for .gitconfig
Message-ID: <alpine.DEB.2.00.1112211352580.17957@ds9.cixit.se>
URL: https://gitlist.dev/e/alpine.DEB.2.00.1112211352580.17957%40ds9.cixit.se
In-Reply-To: <4EEC6A9D.1060005@icefield.yk.ca>

```
Erik Blake:

> As you can see, I'm running git on a Win7 64 machine. Is there any way to 
> escape the brackets? Or do I need to reinstall notepad++ on a different path?

Just use the 8.3 path instead, using either "C:/Progra~1" or "C:/Progra~2" 
(depending on how the system got installed). You can mix 8.3 and long paths 
in the same command (so keeping the "Notepad++" component is fine).

-- 
\\// Peter - http://www.softwolves.pp.se/

```

## demerphq, 2011-12-21 13:59

Subject: Re: Escape character for .gitconfig
Message-ID: <CANgJU+U4Bq0yHmJYndV_4xaymFca2JVNg7sfuN9jB92ts=aFkg@mail.gmail.com>
URL: https://gitlist.dev/e/CANgJU%2BU4Bq0yHmJYndV_4xaymFca2JVNg7sfuN9jB92ts%3DaFkg%40mail.gmail.com
In-Reply-To: <alpine.DEB.2.00.1112211352580.17957@ds9.cixit.se>

```
On 21 December 2011 13:54, Peter Krefting <peter@softwolves.pp.se> wrote:
> Erik Blake:
>
>
>> As you can see, I'm running git on a Win7 64 machine. Is there any way to
>> escape the brackets? Or do I need to reinstall notepad++ on a different
>> path?
>
>
> Just use the 8.3 path instead, using either "C:/Progra~1" or "C:/Progra~2"
> (depending on how the system got installed). You can mix 8.3 and long paths
> in the same command (so keeping the "Notepad++" component is fine).

Or use a junction to make an alias of the name without strange chars....

Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

```
