Re: [PATCH] CodingGuidelines: use octal escapes, not hex
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Jun 13, 2023, 18:16 UTC
- Message-ID
- <CAPig+cRS=cpV1e4QoSy5uypA+-hECyPe2rEg3scV8LVBfzZ5hA@mail.gmail.com>
- In-Reply-To
- <20230613172927.19019-1-jonathantanmy@google.com>
On Tue, Jun 13, 2023 at 1:44 PM Jonathan Tan <jonathantanmy@google.com> wrote:
Show 10 quoted lines
> Hexadecimal escapes in shell scripts are not portable across shells (in > particular, "dash" does not support them). Write in the CodingGuidelines > document that we should be using octal escapes instead. > > Signed-off-by: Jonathan Tan <jonathantanmy@google.com> > --- > diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines > @@ -188,6 +188,9 @@ For shell scripts specifically (not exhaustive): > + - Use octal escape sequences (e.g. "\302\242"), not hexadecimal (e.g. > + "\xc2\xa2"), as the latter is not portable.
The shell itself doesn't interpret these sequences, so this description feels too generic. Perhaps it would make more sense to cite specific tools for which octal sequences are needed for portability reasons, such as `printf`, `sed`, `tr`, etc.