Skip to content

Commit 98ce318

Browse files
committed
Fix early wrapping of the command line when using git-prompt.sh
When running git-prompt in Bash, the lack of \001 and \002 causes the command line to wrap early. The issue is the current \001 and \002 were not themselves escaped and so resulted in binary 0b1 and 0b10 being present, rather than the strings "\001" and "\002". Signed-off-by: Richard Quadling <RQuadling@GMail.com>
1 parent f65182a commit 98ce318

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

contrib/completion/git-prompt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1
147147

148148
# like __git_SOH=$'\001' etc but works also in shells without $'...'
149149
eval "$(printf '
150-
__git_SOH="\001" __git_STX="\002" __git_ESC="\033"
150+
__git_SOH="\\001" __git_STX="\\002" __git_ESC="\033"
151151
__git_LF="\n" __git_CRLF="\r\n"
152152
')"
153153

t/t9903-bash-prompt.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1313
. "$GIT_BUILD_DIR/contrib/completion/git-prompt.sh"
1414

1515
actual="$TRASH_DIRECTORY/actual"
16-
c_red='\001\e[31m\002'
17-
c_green='\001\e[32m\002'
18-
c_lblue='\001\e[1;34m\002'
19-
c_clear='\001\e[0m\002'
16+
c_red='\\001\e[31m\\002'
17+
c_green='\\001\e[32m\\002'
18+
c_lblue='\\001\e[1;34m\\002'
19+
c_clear='\\001\e[0m\\002'
2020

2121
test_expect_success 'setup for prompt tests' '
2222
git init otherrepo &&

0 commit comments

Comments
 (0)