Skip to content

Commit 1971520

Browse files
hyperupcallgitster
authored andcommitted
completion: suppress unwanted unescaping of read
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 <[email protected]> Signed-off-by: Koichi Murase <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 73876f4 commit 1971520

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contrib/completion/git-prompt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ __git_ps1_colorize_gitstring ()
300300
# variable, in that order.
301301
__git_eread ()
302302
{
303-
test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
303+
test -r "$1" && IFS=$'\r\n' read -r "$2" <"$1"
304304
}
305305

306306
# see if a cherry-pick or revert is in progress, if the user has committed a

0 commit comments

Comments
 (0)