Skip to contentSkip to conversation

can not escape sharps in git config file

BUG Jean-Noël Avila 2 participants 4 messages Jun 16, 2016

lore
Share & tools
lore
#0 lore raw

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

#2 lore raw
In reply to Jean-Noël Avila

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

#3 lore raw
Quoted 8 lines · Jean-Noël Avila

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

Quoted 6 lines

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 ?