Skip to content

Commit 5abbdbb

Browse files
committed
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
2 parents 1f24cad + 041fe8f commit 5abbdbb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

contrib/completion/git-prompt.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,12 @@ __git_ps1_colorize_gitstring ()
278278
r="$c_clear$r"
279279
}
280280

281+
# Helper function to read the first line of a file into a variable.
282+
# __git_eread requires 2 arguments, the file path and the name of the
283+
# variable, in that order.
281284
__git_eread ()
282285
{
283-
local f="$1"
284-
shift
285-
test -r "$f" && read "$@" <"$f"
286+
test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
286287
}
287288

288289
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)

0 commit comments

Comments
 (0)