[PATCH v3] CodingGuidelines: use octal escapes, not hex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <jonathantanmy@xxxxxxxxxx>
---
Changes in v3: Used Junio's suggestion [1].

[1] https://lore.kernel.org/git/xmqqy1km28g9.fsf@gitster.g/
---
Range-diff against v2:
1:  c775a0db22 ! 1:  0b7d3ed8f5 CodingGuidelines: use octal escapes, not hex
    @@ Commit message
     
         Signed-off-by: Jonathan Tan <jonathantanmy@xxxxxxxxxx>
         ---
    -    I've used Eric's suggestion for the commit message and limited the scope
    -    of the documentation change to printf.
    +    Changes in v3: Used Junio's suggestion [1].
     
    -    Version 1 was here:
    -    https://lore.kernel.org/git/20230613172927.19019-1-jonathantanmy@xxxxxxxxxx/
    +    [1] https://lore.kernel.org/git/xmqqy1km28g9.fsf@gitster.g/
     
      ## Documentation/CodingGuidelines ##
     @@ Documentation/CodingGuidelines: For shell scripts specifically (not exhaustive):
    @@ Documentation/CodingGuidelines: For shell scripts specifically (not exhaustive):
         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".
    ++   "\xc2\xa2") in printf format strings, since hexadecimal escape
    ++   sequences are not portable.
     +
      
      For C programs:

 Documentation/CodingGuidelines | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 003393ed16..39ef53c237 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") in printf format strings, since hexadecimal escape
+   sequences are not portable.
+
 
 For C programs:
 
-- 
2.41.0.162.gfafddb0af9-goog




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux