git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [Question] Complex textconv text
@ 2018-12-13 15:07 Randall S. Becker
  2018-12-13 16:14 ` Randall S. Becker
  2018-12-14  3:12 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Randall S. Becker @ 2018-12-13 15:07 UTC (permalink / raw)
  To: git

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.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [Question] Complex textconv text
  2018-12-13 15:07 [Question] Complex textconv text Randall S. Becker
@ 2018-12-13 16:14 ` Randall S. Becker
  2018-12-14  3:12 ` Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: Randall S. Becker @ 2018-12-13 16:14 UTC (permalink / raw)
  To: git

On December 13, 2018 10:08, I wrote: 
> 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?

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Question] Complex textconv text
  2018-12-13 15:07 [Question] Complex textconv text Randall S. Becker
  2018-12-13 16:14 ` Randall S. Becker
@ 2018-12-14  3:12 ` Junio C Hamano
  2018-12-14 10:04   ` Jeff King
  1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2018-12-14  3:12 UTC (permalink / raw)
  To: Randall S. Becker; +Cc: git

"Randall S. Becker" <rsbecker@nexbridge.com> writes:

> 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.

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)..

> 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Question] Complex textconv text
  2018-12-14  3:12 ` Junio C Hamano
@ 2018-12-14 10:04   ` Jeff King
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2018-12-14 10:04 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Randall S. Becker, git

On Fri, Dec 14, 2018 at 12:12:01PM +0900, Junio C Hamano wrote:

> > 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.
> 
> 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)..

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-14 10:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-13 15:07 [Question] Complex textconv text Randall S. Becker
2018-12-13 16:14 ` Randall S. Becker
2018-12-14  3:12 ` Junio C Hamano
2018-12-14 10:04   ` Jeff King

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git