Re: [PATCH] git-prompt: fix reading files with windows line endings
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- Nov 30, 2017, 01:08 UTC
- Message-ID
- <20171130010811.17369-1-szeder.dev@gmail.com>
- In-Reply-To
- <alpine.DEB.2.21.1.1711291519290.6482@virtualbox>
Show 10 quoted lines
> > 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.
Gábor