threads / bug / 42435

[BUG] can not escape sharps in git config file

Subject: [BUG] can not escape sharps in git config file

## tl;dr

4 messages between May 24, 2016 and May 25, 2016.

replies: 3people: 2as markdown or json

Jean-Noël Avila· May 24, 2016, 10:14 UTC · lore
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· May 24, 2016, 11:23 UTC · re: Jean-Noël Avila · lore

Re: [BUG] can not escape sharps in git config file

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· May 25, 2016, 05:11 UTC · re: Jean-Noël Avila · lore

Re: [BUG] can not escape sharps in git config file

On 05/24/2016 01:23 PM, Jean-Noël Avila wrote:
Show 14 quoted lines
> 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 ?

← back to recent threads