From: Masahiro Yamada <masahiroy@kernel.org>
To: Nicolas Schier <nicolas@fjasle.eu>
Cc: linux-kbuild@vger.kernel.org,
Nick Desaulniers <ndesaulniers@google.com>,
linux-kernel@vger.kernel.org, Nicholas Piggin <npiggin@gmail.com>,
Nathan Chancellor <nathan@kernel.org>,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] kbuild: single-quote the format string of printf
Date: Wed, 30 Aug 2023 20:33:56 +0900 [thread overview]
Message-ID: <CAK7LNATvUo7gKFG9NjtJarTBM508ntf2v6yo5tXsmDoMcUrJVA@mail.gmail.com> (raw)
In-Reply-To: <ZO3d7DrfKfsDXqa5@bergen.fjasle.eu>
On Wed, Aug 30, 2023 at 10:00 AM Nicolas Schier <nicolas@fjasle.eu> wrote:
>
> On Tue 29 Aug 2023 20:35:31 GMT, Masahiro Yamada wrote:
> > Use single-quotes to avoid escape sequences (\\n).
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
>
> Is this really necessary? Testing w/ GNU Make 4.3, bash 5.2.15 or
> dash 0.5.12-6 and a stupid Makefile snippet I cannot see any difference
> between these three:
>
> print:
> @printf "hello med single-backslash and double quotes\n"
> @printf 'hello med single-backslash and single quotes\n'
> @printf "hello med double-backslash and double quotes\\n"
>
> Only double-backslash+n in single-quotes does not work, for obvious
> reasons.
You are right.
I was misunderstanding the backslash-escaping in double-quotes.
I always used single-quotes when I wanted to avoid
escape sequences.
The following POSIX spec applies here:
2.2.3 Double-Quotes
The <backslash> shall retain its special meaning as an escape character
(see Escape Character (Backslash)) only when followed by one of the
following characters when considered special:
$ ` " \ <newline>
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
All of "\\n", "\n", '\n' are the same.
--
Best Regards
Masahiro Yamada
next prev parent reply other threads:[~2023-08-30 11:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-29 11:35 [PATCH] kbuild: single-quote the format string of printf Masahiro Yamada
2023-08-29 12:00 ` Nicolas Schier
2023-08-30 11:33 ` Masahiro Yamada [this message]
2023-08-30 13:00 ` David Laight
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAK7LNATvUo7gKFG9NjtJarTBM508ntf2v6yo5tXsmDoMcUrJVA@mail.gmail.com \
--to=masahiroy@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nicolas@fjasle.eu \
--cc=npiggin@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).