Fix infinite loop when $PS4 calls external command
When using `set -x` with a `$PS4` variable which calls a external command (e.g. `PS4='+ $(true)'`) the color functions end in a infite loop. The solution is `shift` the arguments unconditionally in the color funtions. This fixes #546pull/547/head
parent
2541ca965a
commit
2360790ee3
|
|
@ -5,54 +5,54 @@ function __ {
|
||||||
}
|
}
|
||||||
|
|
||||||
function __make_ansi {
|
function __make_ansi {
|
||||||
next=$1 && shift
|
next=$1; shift
|
||||||
echo "\[\e[$(__$next $@)m\]"
|
echo "\[\e[$(__$next $@)m\]"
|
||||||
}
|
}
|
||||||
|
|
||||||
function __make_echo {
|
function __make_echo {
|
||||||
next=$1 && shift
|
next=$1; shift
|
||||||
echo "\033[$(__$next $@)m"
|
echo "\033[$(__$next $@)m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function __reset {
|
function __reset {
|
||||||
next=$1 && shift
|
next=$1; shift
|
||||||
out="$(__$next $@)"
|
out="$(__$next $@)"
|
||||||
echo "0${out:+;${out}}"
|
echo "0${out:+;${out}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function __bold {
|
function __bold {
|
||||||
next=$1 && shift
|
next=$1; shift
|
||||||
out="$(__$next $@)"
|
out="$(__$next $@)"
|
||||||
echo "${out:+${out};}1"
|
echo "${out:+${out};}1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function __faint {
|
function __faint {
|
||||||
next=$1 && shift
|
next=$1; shift
|
||||||
out="$(__$next $@)"
|
out="$(__$next $@)"
|
||||||
echo "${out:+${out};}2"
|
echo "${out:+${out};}2"
|
||||||
}
|
}
|
||||||
|
|
||||||
function __italic {
|
function __italic {
|
||||||
next=$1 && shift
|
next=$1; shift
|
||||||
out="$(__$next $@)"
|
out="$(__$next $@)"
|
||||||
echo "${out:+${out};}3"
|
echo "${out:+${out};}3"
|
||||||
}
|
}
|
||||||
|
|
||||||
function __underline {
|
function __underline {
|
||||||
next=$1 && shift
|
next=$1; shift
|
||||||
out="$(__$next $@)"
|
out="$(__$next $@)"
|
||||||
echo "${out:+${out};}4"
|
echo "${out:+${out};}4"
|
||||||
}
|
}
|
||||||
|
|
||||||
function __negative {
|
function __negative {
|
||||||
next=$1 && shift
|
next=$1; shift
|
||||||
out="$(__$next $@)"
|
out="$(__$next $@)"
|
||||||
echo "${out:+${out};}7"
|
echo "${out:+${out};}7"
|
||||||
}
|
}
|
||||||
|
|
||||||
function __crossed {
|
function __crossed {
|
||||||
next=$1 && shift
|
next=$1; shift
|
||||||
out="$(__$next $@)"
|
out="$(__$next $@)"
|
||||||
echo "${out:+${out};}8"
|
echo "${out:+${out};}8"
|
||||||
}
|
}
|
||||||
|
|
@ -114,18 +114,18 @@ function __color_rgb {
|
||||||
}
|
}
|
||||||
|
|
||||||
function __color {
|
function __color {
|
||||||
color=$1 && shift
|
color=$1; shift
|
||||||
case "$1" in
|
case "$1" in
|
||||||
fg|bg) side="$1" && shift ;;
|
fg|bg) side="$1"; shift ;;
|
||||||
*) side=fg;;
|
*) side=fg;;
|
||||||
esac
|
esac
|
||||||
case "$1" in
|
case "$1" in
|
||||||
normal|bright) mode="$1" && shift;;
|
normal|bright) mode="$1"; shift;;
|
||||||
*) mode=normal;;
|
*) mode=normal;;
|
||||||
esac
|
esac
|
||||||
[[ $color == "rgb" ]] && rgb="$1 $2 $3" && shift 3
|
[[ $color == "rgb" ]] && rgb="$1 $2 $3"; shift 3
|
||||||
|
|
||||||
next=$1 && shift
|
next=$1; shift
|
||||||
out="$(__$next $@)"
|
out="$(__$next $@)"
|
||||||
echo "$(__color_${mode}_${side} $(__color_${color} $rgb))${out:+;${out}}"
|
echo "$(__color_${mode}_${side} $(__color_${color} $rgb))${out:+;${out}}"
|
||||||
}
|
}
|
||||||
|
|
@ -169,7 +169,7 @@ function __rgb {
|
||||||
|
|
||||||
|
|
||||||
function __color_parse {
|
function __color_parse {
|
||||||
next=$1 && shift
|
next=$1; shift
|
||||||
echo "$(__$next $@)"
|
echo "$(__$next $@)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue