{"thread":{"id":"50028","subject":"[Question] Complex textconv text","startedAt":"2018-12-13T15:07:48Z","lastAt":"2018-12-14T10:05:00Z","messageCount":4,"participants":["Randall S. Becker","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"365258","messageId":"004501d492f5$98f0fcc0$cad2f640$@nexbridge.com","threadId":"50028","inReplyTo":null,"subject":"[Question] Complex textconv text","fromName":"Randall S. Becker","fromEmail":"rsbecker@nexbridge.com","sentAt":"2018-12-13T15:07:37Z","receivedAt":"2018-12-13T15:07:48Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"Hi all,\n\nI have a strange situation and need help with resolving funky characters in\n.git/config. My situation is this:\n\n[diff \"*.dat\"]\n\ttextconv = enscribe-conv\n--format=-a1\\(A=-a1,-a16,-a32\\|P=-a1,-a32,-a16\\|=-a1,-d,a14\\),-a224\n\nBasically this is a formatter for diff so that I can show structured binary\ndata. The unquoted syntax of the format string is:\n --format=-a1(A=-a1,-a16,-a32|P=-a1,-a32,-a16|=-a1,-d,a14),-a224\n\nContent is not really important. The issue is that git is reporting fatal:\nbad config line 2 in file .git/config when I escape the (, ), and |\ncharacters. I get syntax errors otherwise from the shell running the\ntextconv. I have tried\n--format=\"-a1(A=-a1,-a16,-a32|P=-a1,-a32,-a16|=-a1,-d,a14),-a224\", to no\navail. How should I safely escape the characters in here?\n\nThanks,\nRandall\n\n-- Brief whoami:\n NonStop developer since approximately 211288444200000000\n UNIX developer since approximately 421664400\n-- In my real life, I talk too much.\n\n\n\n"},{"id":"365270","messageId":"005101d492fe$fde97130$f9bc5390$@nexbridge.com","threadId":"50028","inReplyTo":"004501d492f5$98f0fcc0$cad2f640$@nexbridge.com","subject":"RE: [Question] Complex textconv text","fromName":"Randall S. Becker","fromEmail":"rsbecker@nexbridge.com","sentAt":"2018-12-13T16:14:52Z","receivedAt":"2018-12-13T16:15:01Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On December 13, 2018 10:08, I wrote: \n> I have a strange situation and need help with resolving funky characters\nin\n> .git/config. My situation is this:\n> \n> [diff \"*.dat\"]\n> \ttextconv = enscribe-conv\n> --format=-a1\\(A=-a1,-a16,-a32\\|P=-a1,-a32,-a16\\|=-a1,-d,a14\\),-a224\n> \n> Basically this is a formatter for diff so that I can show structured\nbinary data.\n> The unquoted syntax of the format string is:\n>  --format=-a1(A=-a1,-a16,-a32|P=-a1,-a32,-a16|=-a1,-d,a14),-a224\n> \n> Content is not really important. The issue is that git is reporting fatal:\n> bad config line 2 in file .git/config when I escape the (, ), and |\ncharacters. I\n> get syntax errors otherwise from the shell running the textconv. I have\ntried -\n> -format=\"-a1(A=-a1,-a16,-a32|P=-a1,-a32,-a16|=-a1,-d,a14),-a224\", to no\n> avail. How should I safely escape the characters in here?\n\nEasiest bypass was to wrap the mess above into a shell script and execute it\nthat way, which works just fine. I'm not sure it's possible to escape all of\nthe special characters. Seems like the safest approach anyway.\n\nCheers,\nRandall\n\n"},{"id":"365322","messageId":"xmqqo99odcou.fsf@gitster-ct.c.googlers.com","threadId":"50028","inReplyTo":"004501d492f5$98f0fcc0$cad2f640$@nexbridge.com","subject":"Re: [Question] Complex textconv text","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-12-14T03:12:01Z","receivedAt":"2018-12-14T03:12:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Randall S. Becker\" <rsbecker@nexbridge.com> writes:\n\n> Hi all,\n>\n> I have a strange situation and need help with resolving funky characters in\n> .git/config. My situation is this:\n>\n> [diff \"*.dat\"]\n> \ttextconv = enscribe-conv\n> --format=-a1\\(A=-a1,-a16,-a32\\|P=-a1,-a32,-a16\\|=-a1,-d,a14\\),-a224\n>\n> Basically this is a formatter for diff so that I can show structured binary\n> data. The unquoted syntax of the format string is:\n>  --format=-a1(A=-a1,-a16,-a32|P=-a1,-a32,-a16|=-a1,-d,a14),-a224\n>\n> Content is not really important. The issue is that git is reporting fatal:\n> bad config line 2 in file .git/config when I escape the (, ), and |\n> characters.\n\nThat failure is understandable, as\n\n    The following escape sequences (beside `\\\"` and `\\\\`) are recognized:\n    `\\n` for newline character (NL), `\\t` for horizontal tabulation (HT, TAB)\n    and `\\b` for backspace (BS).  Other char escape sequences (including octal\n    escape sequences) are invalid.\n\nis what Documentation/config.txt says.  \\(, \\) and \\| is not a way\nto escape these letters from the .git/config parser (they do not\nneed to be escaped from .git/config parser)..\n\n> I get syntax errors otherwise from the shell running the\n> textconv. I have tried\n> --format=\"-a1(A=-a1,-a16,-a32|P=-a1,-a32,-a16|=-a1,-d,a14),-a224\", to no\n> avail.\n\nWould \n\n\ttextconv = enscribe-conv --format=\\\"-a1(A=...,-a224\\\"\n\nwork?\n\nWe want to show the shell what you wrote so that pipes and parens\nare inside a dq pair, but the .git/config language strips pair of\ndq, so the .git/config language parser needs to be told that these\ndq are not for it to eat.\n"},{"id":"365336","messageId":"20181214100457.GB13465@sigill.intra.peff.net","threadId":"50028","inReplyTo":"xmqqo99odcou.fsf@gitster-ct.c.googlers.com","subject":"Re: [Question] Complex textconv text","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-12-14T10:04:57Z","receivedAt":"2018-12-14T10:05:00Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Dec 14, 2018 at 12:12:01PM +0900, Junio C Hamano wrote:\n\n> > I have a strange situation and need help with resolving funky characters in\n> > .git/config. My situation is this:\n> >\n> > [diff \"*.dat\"]\n> > \ttextconv = enscribe-conv\n> > --format=-a1\\(A=-a1,-a16,-a32\\|P=-a1,-a32,-a16\\|=-a1,-d,a14\\),-a224\n> >\n> > Basically this is a formatter for diff so that I can show structured binary\n> > data. The unquoted syntax of the format string is:\n> >  --format=-a1(A=-a1,-a16,-a32|P=-a1,-a32,-a16|=-a1,-d,a14),-a224\n> >\n> > Content is not really important. The issue is that git is reporting fatal:\n> > bad config line 2 in file .git/config when I escape the (, ), and |\n> > characters.\n> \n> That failure is understandable, as\n> \n>     The following escape sequences (beside `\\\"` and `\\\\`) are recognized:\n>     `\\n` for newline character (NL), `\\t` for horizontal tabulation (HT, TAB)\n>     and `\\b` for backspace (BS).  Other char escape sequences (including octal\n>     escape sequences) are invalid.\n> \n> is what Documentation/config.txt says.  \\(, \\) and \\| is not a way\n> to escape these letters from the .git/config parser (they do not\n> need to be escaped from .git/config parser)..\n\nYes. It's a little unfriendly that we don't pass them through, since\nthat would do what Randall wants here. But doing so would be unfriendly\nto somebody who _did_ want to quote them, and is confused why there are\npassed through literally.\n\nAt any rate, the \"right\" way here is to quote the backslashes that are\nmeant to be passed through to the shell, like:\n\n  textconv = foo \\\\(X\\\\|\\\\)\n\nNote that if you write the config using git-config, that's what it\nproduces:\n\n  $ git config -f file foo.bar '\\(X\\|Y\\)'\n  $ cat file\n  [foo]\n\tbar = \\\\(X\\\\|Y\\\\)\n\nI agree that your double-quote suggestion is more readable (or as\nRandall eventually figured out, hiding it all in a real script ;) ).\n\n-Peff\n"}]}