Thread (1 message) 1 message, 1 author, 2023-06-14

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

From: Junio C Hamano <hidden>
Date: 2023-06-14 00:28:42

Jonathan Tan [off-list ref] writes:
quoted hunk
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.

Signed-off-by: Jonathan Tan <redacted>
---
I've used Eric's suggestion for the commit message and limited the scope
of the documentation change to printf.

Version 1 was here:
https://lore.kernel.org/git/20230613172927.19019-1-jonathantanmy@google.com/ (local)
---
 Documentation/CodingGuidelines | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 003393ed16..30ac7d2d3f 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -188,6 +188,10 @@ For shell scripts specifically (not exhaustive):
    hopefully nobody starts using "local" before they are reimplemented
    in C ;-)
 
+ - Use octal escape sequences (e.g. "\302\242"), not hexadecimal (e.g.
+   "\xc2\xa2"), since the latter is not portable across commands like
+   "printf".
I'd say

    - Use octal ... not hex..., in printf format string.

not "commands LIKE".

Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help