Subject: Re: [PATCH] CodingGuidelines: use octal escapes, not hex

From: Junio C Hamano <[email-masked]>
Date: Tue, 13 Jun 2023 12:29:04 -0700

Eric Sunshine <[email-masked]> 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.