Unverified Commit a1d0a540 authored by Mark Vander Stel's avatar Mark Vander Stel
Browse files

Fix bash __lp_escape() for backtick expansion

For some reason, Bash ignores a '\$' sequence when the promptvars option
is off, printing it as '$'. It does not do the same for a backtick
escaped: '\`' is printed as '\`'. To prevent this issue, detect if the
option is on, and if so, escape both '$' and '`'.

Running 'shopt' is actually faster than either a [[ ]] or (( ))
parent e3eb48ba
......@@ -49,8 +49,11 @@ if test -n "${BASH_VERSION-}"; then
# Must be used for all strings injected in PS1 that may comes from remote sources,
# like $PWD, VCS branch names...
__lp_escape() {
local arg="${1//\\/\\\\}"
if shopt -q promptvars ; then
elif test -n "${ZSH_VERSION-}" ; then
# Check for recent enough version of zsh.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment