Re: [PATCH] CodingGuidelines: use octal escapes, not hex
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 13, 2023, 19:29 UTC
- Message-ID
- <xmqq1qif5fgf.fsf@gitster.g>
- In-Reply-To
- <CAPig+cQnyL8-9EHVe5P_oRbUdsXA9WBiK_W4LHq7HOF4-ek5Pg@mail.gmail.com>
Eric Sunshine <sunshine@sunshineco.com> writes:
Show 12 quoted lines
> So, for the commit message, perhaps simply: > > Extend the shell-scripting section of CodingGuidelines to suggest > octal escape sequences (e.g. "\302\242") over hexadecimal > (e.g. "\xc2\xa2") since the latter can be a source of portability > problems. > > As for the change to CodingGuidelines, this would probably be sufficient: > > Use octal escape sequences (e.g. "\302\242"), not hexadecimal > (e.g. "\xc2\xa2"), since the latter is not portable across some > commands, such as `printf`, `sed`, `tr`, etc.
I'd prefer singling out `printf`, actually, and not talking about "across some commands".
As I said in a separate message, we certainly do *not* want to rely on `echo` interpreting bs-escaped octal sequences without '-e', even though it may be expected on a POSIX systems, because it is not portable across systems our users commonly encounter.
And `printf` has been what we chose to turn bs-escaped octal sequence into binary. I'd prefer not having to even worry about `sed`, `tr`, etc. behaving differently and not allowing to expect these other commands to be usable for turning bs-escaped octal sequence into binary would be one way to achieve that goal.
Thanks.