From: Junio C Hamano <gitster@pobox.com>
To: Marcel Telka <marcel@telka.sk>
Cc: Eric Sunshine <sunshine@sunshineco.com>, git@vger.kernel.org
Subject: Re: [PATCH] t/t9902-completion.sh: backslashes in echo
Date: Thu, 23 May 2024 16:03:54 -0700 [thread overview]
Message-ID: <xmqqcypcqgf9.fsf@gitster.g> (raw)
In-Reply-To: <Zk_FiYd8uk-P5jIi@telcontar> (Marcel Telka's message of "Fri, 24 May 2024 00:39:05 +0200")
Marcel Telka <marcel@telka.sk> writes:
> Okay, I found the cause. Bash on OpenIndiana is compiled with
> --enable-xpg-echo-default so escape sequencies are expanded by default.
>
>> OTOH, it seems that the fix is maybe not needed because it is solving a
>> non-problem.
>
> There is a problem, but definitely the justification in the commit
> message is not accurate because we do not care about POSIX here at all.
> Also maybe it would be better/simpler to use `echo -E` instead of
> `printf`, but I'm not sure here.
How "portable" is "echo -E"? It apparently is not listd in [*], but
it should probably not matter as we are doing this in bash.
printf is a kosher way whose behaviour is pretty well standardized
especially with respect to "%s". As I said that I was going to
merge it down to 'master' already, it is now part of 'master'.
Use of printf there may hopefully educate folks to think twice
before using 'echo' on unknown data.
By the way, it makes me feel funny that we are talking about "POSIX
portability" when reviewing a change like this:
print_comp ()
{
local IFS=$'\n'
- echo "${COMPREPLY[*]}" > out
+ printf '%s\n' "${COMPREPLY[*]}" > out
}
With "${ARRAY[*]}", POSIX portability is totally out of the water
anyway, regardless of the echo/printf issue ;-).
[Reference]
* https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html
next prev parent reply other threads:[~2024-05-23 23:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-17 14:08 [PATCH] t/t9902-completion.sh: backslashes in echo Marcel Telka
2024-05-23 17:59 ` Junio C Hamano
2024-05-23 20:31 ` Marcel Telka
2024-05-23 21:06 ` Eric Sunshine
2024-05-23 21:47 ` Marcel Telka
2024-05-23 22:39 ` Marcel Telka
2024-05-23 22:45 ` Marcel Telka
2024-05-23 23:03 ` Junio C Hamano [this message]
2024-05-23 23:14 ` Eric Sunshine
2024-05-23 23:21 ` Marcel Telka
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=xmqqcypcqgf9.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=marcel@telka.sk \
--cc=sunshine@sunshineco.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).