Re: [PATCH] git-prompt: fix reading files with windows line endings
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- Nov 30, 2017, 23:45 UTC
- Message-ID
- <CAM0VKjnpUNhMJk6wk1prtvr2SjOuhMLKWQ7zf8S6w-0yfD5WcQ@mail.gmail.com>
- In-Reply-To
- <alpine.DEB.2.21.1.1711300250320.6482@virtualbox>
On Thu, Nov 30, 2017 at 2:51 AM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 26 quoted lines
> On Thu, 30 Nov 2017, SZEDER Gábor wrote:
>
>> > > diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
>> > > index c6cbef38c2..71a64e7959 100644
>> > > --- a/contrib/completion/git-prompt.sh
>> > > +++ b/contrib/completion/git-prompt.sh
>> > > @@ -282,7 +282,7 @@ __git_eread ()
>> > > {
>> > > local f="$1"
>> > > shift
>> > > - test -r "$f" && read "$@" <"$f"
>> > > + test -r "$f" && read "$@" <"$f" && export $@="${!@%$'\r'}"
>>
>> I don't think that export is necessary here.
>>
>> > As far as I understand, $'\r' is a Bash-only construct, and this file
>> > (git-prompt.sh) is targeting other Unix shells, too.
>>
>> The only other shell the prompt (and completion) script is targeting
>> is ZSH, and ZSH understands this construct. We already use this
>> construct to set IFS in several places in both scripts for a long
>> time, so it should be fine here, too.
>
> That's good to know! I should have `git grep`ped...
>
> Sorry for the noise,No, no, your concern is justified, you just happened to pick the wrong construct :)
It's the ${!var} indirect expansion construct that ZSH doesn't know, it uses a different syntax for that.
Gábor