diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-12-28 14:08:45 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-12-28 14:08:45 -0800 |
commit | 5abbdbbd9bd32aaae0e11d078b0151f7a7e3d20d (patch) | |
tree | 41a12d0f47ebf86c91492097bf7a3ef05d4db0ec /contrib | |
parent | Merge branch 'bw/path-doc' (diff) | |
parent | git-prompt: fix reading files with windows line endings (diff) | |
download | tgif-5abbdbbd9bd32aaae0e11d078b0151f7a7e3d20d.tar.xz |
Merge branch 'ra/prompt-eread-fix'
Update the shell prompt script (in contrib/) to strip trailing CR
from strings read from various "state" files.
* ra/prompt-eread-fix:
git-prompt: fix reading files with windows line endings
git-prompt: make __git_eread intended use explicit
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/completion/git-prompt.sh | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index c6cbef38c2..983e419d2b 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -278,11 +278,12 @@ __git_ps1_colorize_gitstring () r="$c_clear$r" } +# Helper function to read the first line of a file into a variable. +# __git_eread requires 2 arguments, the file path and the name of the +# variable, in that order. __git_eread () { - local f="$1" - shift - test -r "$f" && read "$@" <"$f" + test -r "$1" && IFS=$'\r\n' read "$2" <"$1" } # __git_ps1 accepts 0 or 1 arguments (i.e., format string) |