git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 14, 2023, 00:28 UTC
Message-ID
<xmqqy1km28g9.fsf@gitster.g>
In-Reply-To
<20230614001558.277755-1-jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 26 quoted lines
> 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@google.com>
> ---
> 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/
> ---
>  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.
Previous: Jonathan TanNext: Jonathan Tan
Message 2 of 4 in “CodingGuidelines: use octal escapes, not hex”
  1. CodingGuidelines: use octal escapes, not hexJonathan Tan, Jun 14, 2023
  2. Junio C HamanoJun 14, 2023
  3. CodingGuidelines: use octal escapes, not hexJonathan Tan, Jun 14, 2023
  4. Junio C HamanoJun 14, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.