# [BUG] can not escape sharps in git config file

4 messages from 2016-05-24 to 2016-05-25. Participants: Jean-Noël Avila, Torsten Bögershausen.
Thread: https://gitlist.dev/t/42435

## Jean-Noël Avila, 2016-05-24 10:14

Subject: [BUG] can not escape sharps in git config file
Message-ID: <57442992.6030306@gmail.com>
URL: https://gitlist.dev/e/57442992.6030306%40gmail.com

```
Hi everyone,

I stumbled on this:

config file:

[filter "kicad_sch"]
        clean = sed -E 's/#(PWR|FLG)[0-9]+/#\1?/'
        smudge = cat


Then in the shell:

± git add -u
sed -E 's/: 1: sed -E 's/: Syntax error: Unterminated quoted string
error: external filter sed -E 's/ failed 2
error: external filter sed -E 's/ failed

It seems that the  # is used for end-of-line comments and can not be
escaped, even in quotes or backslash.

JN

```

## Jean-Noël Avila, 2016-05-24 10:25

Subject: Re: [BUG] can not escape sharps in git config file
Message-ID: <57442C2A.3010202@gmail.com>
URL: https://gitlist.dev/e/57442C2A.3010202%40gmail.com
In-Reply-To: <57442992.6030306@gmail.com>

```
Forgot to add:

± git --version
git version 2.8.3

```

## Jean-Noël Avila, 2016-05-24 11:23

Subject: Re: [BUG] can not escape sharps in git config file
Message-ID: <574439B3.9090308@gmail.com>
URL: https://gitlist.dev/e/574439B3.9090308%40gmail.com
In-Reply-To: <57442992.6030306@gmail.com>

```
My mistake, sorry for the noise,

JFTR:

 * only double quotes can fully escape a string (it is safer to enclose
the whole value in double quotes)
 * backslashes have to be doubled because they are interpreted by git

So

[filter "kicad_sch"]
    clean = "sed -E 's/#(PWR|FLG)[0-9]+/#\\1?/'"
    smudge = cat

JN

```

## Torsten Bögershausen, 2016-05-25 05:11

Subject: Re: [BUG] can not escape sharps in git config file
Message-ID: <5745341E.4080305@web.de>
URL: https://gitlist.dev/e/5745341E.4080305%40web.de
In-Reply-To: <574439B3.9090308@gmail.com>

```
On 05/24/2016 01:23 PM, Jean-Noël Avila wrote:
> My mistake, sorry for the noise,
>
> JFTR:
>
>   * only double quotes can fully escape a string (it is safer to enclose
> the whole value in double quotes)
>   * backslashes have to be doubled because they are interpreted by git
>
> So
>
> [filter "kicad_sch"]
>      clean = "sed -E 's/#(PWR|FLG)[0-9]+/#\\1?/'"
>      smudge = cat
>
(I'm not a filter expert)
What happens if you put the sed expression into a shell script, and
configure the filter to call the script instead ?

```
