Re: [PATCH] CodingGuidelines: use octal escapes, not hex
From: Junio C Hamano <hidden>
Date: 2023-06-13 19:29:09
Eric Sunshine [off-list ref] writes:
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.