Skip to contentSkip to conversation

Complex textconv text

Question Randall S. Becker 3 participants 4 messages Dec 13, 2018 – Dec 14, 2018

lore
Share & tools
lore
#0 lore raw

Hi all,

I have a strange situation and need help with resolving funky characters in .git/config. My situation is this:

[diff "*.dat"]
textconv = enscribe-conv
--format=-a1\(A=-a1,-a16,-a32\|P=-a1,-a32,-a16\|=-a1,-d,a14\),-a224

Basically this is a formatter for diff so that I can show structured binary data. The unquoted syntax of the format string is:
--format=-a1(A=-a1,-a16,-a32|P=-a1,-a32,-a16|=-a1,-d,a14),-a224

Content is not really important. The issue is that git is reporting fatal:
bad config line 2 in file .git/config when I escape the (, ), and | characters. I get syntax errors otherwise from the shell running the textconv. I have tried --format="-a1(A=-a1,-a16,-a32|P=-a1,-a32,-a16|=-a1,-d,a14),-a224", to no avail. How should I safely escape the characters in here?

Thanks,
Randall

-- Brief whoami:
NonStop developer since approximately 211288444200000000 UNIX developer since approximately 421664400
-- In my real life, I talk too much.

#1 lore raw
Quoted 1 line · On December 13, 2018 10:08, I wrote:

I have a strange situation and need help with resolving funky characters

in

Quoted 7 lines

.git/config. My situation is this:

[diff "*.dat"]
textconv = enscribe-conv
--format=-a1\(A=-a1,-a16,-a32\|P=-a1,-a32,-a16\|=-a1,-d,a14\),-a224

Basically this is a formatter for diff so that I can show structured

binary data.

Quoted 5 lines

The unquoted syntax of the format string is:
--format=-a1(A=-a1,-a16,-a32|P=-a1,-a32,-a16|=-a1,-d,a14),-a224

Content is not really important. The issue is that git is reporting fatal:
bad config line 2 in file .git/config when I escape the (, ), and |

characters. I

Quoted 1 line

get syntax errors otherwise from the shell running the textconv. I have

tried -

Quoted 2 lines

-format="-a1(A=-a1,-a16,-a32|P=-a1,-a32,-a16|=-a1,-d,a14),-a224", to no avail. How should I safely escape the characters in here?

Easiest bypass was to wrap the mess above into a shell script and execute it that way, which works just fine. I'm not sure it's possible to escape all of the special characters. Seems like the safest approach anyway.

Cheers,
Randall

#2 lore raw
In reply to Randall S. Becker
Quoted 9 lines · Randall S. Becker

Hi all,

I have a strange situation and need help with resolving funky characters in .git/config. My situation is this:

[diff "*.dat"]
textconv = enscribe-conv
--format=-a1\(A=-a1,-a16,-a32\|P=-a1,-a32,-a16\|=-a1,-d,a14\),-a224

Quoted 7 lines

Basically this is a formatter for diff so that I can show structured binary data. The unquoted syntax of the format string is:
--format=-a1(A=-a1,-a16,-a32|P=-a1,-a32,-a16|=-a1,-d,a14),-a224

Content is not really important. The issue is that git is reporting fatal:
bad config line 2 in file .git/config when I escape the (, ), and | characters.

That failure is understandable, as

The following escape sequences (beside \" and \\) are recognized:
\n for newline character (NL), \t for horizontal tabulation (HT, TAB) and \b for backspace (BS). Other char escape sequences (including octal escape sequences) are invalid.

is what Documentation/config.txt says. \(, \) and \| is not a way to escape these letters from the .git/config parser (they do not need to be escaped from .git/config parser)..

Quoted 4 lines

I get syntax errors otherwise from the shell running the textconv. I have tried --format="-a1(A=-a1,-a16,-a32|P=-a1,-a32,-a16|=-a1,-d,a14),-a224", to no avail.

Would

	textconv = enscribe-conv --format=\"-a1(A=...,-a224\"

work?

We want to show the shell what you wrote so that pipes and parens are inside a dq pair, but the .git/config language strips pair of dq, so the .git/config language parser needs to be told that these dq are not for it to eat.

#3 lore raw
Quoted 17 lines · Junio C Hamano
Quoted 7 lines

I have a strange situation and need help with resolving funky characters in .git/config. My situation is this:

[diff "*.dat"]
textconv = enscribe-conv
--format=-a1\(A=-a1,-a16,-a32\|P=-a1,-a32,-a16\|=-a1,-d,a14\),-a224

Quoted 7 lines

Basically this is a formatter for diff so that I can show structured binary data. The unquoted syntax of the format string is:
--format=-a1(A=-a1,-a16,-a32|P=-a1,-a32,-a16|=-a1,-d,a14),-a224

Content is not really important. The issue is that git is reporting fatal:
bad config line 2 in file .git/config when I escape the (, ), and | characters.

That failure is understandable, as

Quoted 8 lines

The following escape sequences (beside \" and \\) are recognized:
\n for newline character (NL), \t for horizontal tabulation (HT, TAB) and \b for backspace (BS). Other char escape sequences (including octal escape sequences) are invalid.

is what Documentation/config.txt says. \(, \) and \| is not a way to escape these letters from the .git/config parser (they do not need to be escaped from .git/config parser)..

Yes. It's a little unfriendly that we don't pass them through, since that would do what Randall wants here. But doing so would be unfriendly to somebody who _did_ want to quote them, and is confused why there are passed through literally.

At any rate, the "right" way here is to quote the backslashes that are meant to be passed through to the shell, like:

textconv = foo \\(X\\|\\)

Note that if you write the config using git-config, that's what it produces:

  $ git config -f file foo.bar '\(X\|Y\)'
  $ cat file
  [foo]
	bar = \\(X\\|Y\\)

I agree that your double-quote suggestion is more readable (or as Randall eventually figured out, hiding it all in a real script ;) ).

-Peff