From: Junio C Hamano <gitster@pobox•com>
To: Koichi Murase <myoga.murase@gmail•com>
Cc: git@vger•kernel.org,
"Justin Donnelly" <justinrdonnelly@gmail•com>,
"Denton Liu" <liu.denton@gmail•com>,
"SZEDER Gábor" <szeder.dev@gmail•com>,
"Edwin Kofler" <edwin@kofler•dev>
Subject: Re: [PATCH] completion: suppress unwanted unescaping of `read`
Date: Thu, 20 Apr 2023 15:47:28 -0700 [thread overview]
Message-ID: <xmqqjzy6p3wf.fsf@gitster.g> (raw)
In-Reply-To: <20230420223800.1698197-1-myoga.murase@gmail.com> (Koichi Murase's message of "Fri, 21 Apr 2023 07:38:00 +0900")
Koichi Murase <myoga.murase@gmail•com> writes:
> From: Edwin Kofler <edwin@kofler•dev>
>
> The function `__git_eread`, which reads the first line from the file,
> calls the `read` builtin without passing the flag option `-r`. When
> the `read` builtin is called without the flag `-r`, it processes the
> backslash escaping in the text that it reads. For this reason, it is
> generally considered the best practice to always use the `read`
> builtin with flag `-r` unless one intensionally processes the
> backslash escaping. For the present case in git-prompt.sh, in fact,
> all the occurrences of the calls of `__git_eread` intend to read the
> literal content of the first lines.
>
> To make it read the first line literally, pass the flag `-r` to the
> `read` builtin in the function `__git_eread`.
>
> Signed-off-by: Edwin Kofler <edwin@kofler•dev>
> Signed-off-by: Koichi Murase <myoga.murase@gmail•com>
> ---
> contrib/completion/git-prompt.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
> index 9c10690a22..49dd69bb84 100644
> --- a/contrib/completion/git-prompt.sh
> +++ b/contrib/completion/git-prompt.sh
> @@ -298,7 +298,7 @@ __git_ps1_colorize_gitstring ()
> # variable, in that order.
> __git_eread ()
> {
> - test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
> + test -r "$1" && IFS=$'\r\n' read -r "$2" <"$1"
> }
>
> # see if a cherry-pick or revert is in progress, if the user has committed a
Perfect. Will queue. Thanks.
next prev parent reply other threads:[~2023-04-20 22:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 7:46 [PATCH 1/2] completion: quote arguments of test and [ Koichi Murase
2023-04-20 7:46 ` [PATCH 2/2] completion: suppress unwanted unescaping of `read` Koichi Murase
2023-04-20 16:45 ` Junio C Hamano
2023-04-20 22:31 ` Koichi Murase
2023-04-20 22:38 ` [PATCH] " Koichi Murase
2023-04-20 22:47 ` Junio C Hamano [this message]
2023-04-24 13:52 ` Felipe Contreras
2023-04-20 16:31 ` [PATCH 1/2] completion: quote arguments of test and [ Junio C Hamano
2023-04-20 20:59 ` Koichi Murase
2023-04-24 13:43 ` Felipe Contreras
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=xmqqjzy6p3wf.fsf@gitster.g \
--to=gitster@pobox$(echo .)com \
--cc=edwin@kofler$(echo .)dev \
--cc=git@vger$(echo .)kernel.org \
--cc=justinrdonnelly@gmail$(echo .)com \
--cc=liu.denton@gmail$(echo .)com \
--cc=myoga.murase@gmail$(echo .)com \
--cc=szeder.dev@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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