Skip to content

Commit 632b24f

Browse files
committed
Add special escape sequences to PS1
Color sequences have to be bracketed by \[ and \] to keep Bash from counting those characters when determining the prompt length. Failure to account for this results in broken line wrapping for long shell input.
1 parent 3d9f57b commit 632b24f

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

zfsbootmenu/bin/zfs-chroot

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@ cleanup() {
1212
trap - HUP INT QUIT ABRT EXIT
1313
}
1414

15-
# shellcheck disable=SC1091
16-
source /lib/profiling-lib.sh >/dev/null 2>&1
17-
# shellcheck disable=SC1091
18-
source /etc/zfsbootmenu.conf 2>&1 || exit 1
19-
# shellcheck disable=SC1091
20-
source /lib/kmsg-log-lib.sh >/dev/null 2>&1 || exit 1
21-
# shellcheck disable=SC1091
22-
source /lib/zfsbootmenu-core.sh >/dev/null 2>&1 || exit 1
15+
sources=(
16+
/lib/profiling-lib.sh
17+
/etc/zfsbootmenu.conf
18+
/lib/kmsg-log-lib.sh
19+
/lib/zfsbootmenu-core.sh
20+
)
21+
22+
for src in "${sources[@]}"; do
23+
# shellcheck disable=SC1090
24+
source "${src}" >/dev/null 2>&1 || exit 1
25+
done
26+
27+
unset src sources
2328

2429
selected="${1}"
2530

@@ -82,6 +87,6 @@ fi
8287
echo -e "$( colorize orange "${selected}") is mounted ${writemode}, /tmp is shared and read/write\n"
8388

8489
# regardless of shell, set PS1
85-
if ! env "PS1=$( colorize orange "${selected}") \w > " chroot "${mountpoint}" "${_SHELL}" "${chroot_extra}" ; then
90+
if ! env "PS1=\[\033[0;33m\]${selected}\[\033[0m\] \w > " chroot "${mountpoint}" "${_SHELL}" "${chroot_extra}" ; then
8691
zdebug "chroot ${selected}:${_SHELL} returned code $?"
8792
fi

zfsbootmenu/install-helpers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ create_zbm_profiles() {
127127
[ -f /etc/profile ] && source /etc/profile
128128
[ -f /lib/zfsbootmenu-completions.sh ] && source /lib/zfsbootmenu-completions.sh
129129
130-
export PS1="\033[0;33mzfsbootmenu\033[0m \w > "
130+
export PS1="\[\033[0;33m\]zfsbootmenu\[\033[0m\] \w > "
131131
132132
alias clear="tput clear"
133133
alias reset="tput reset"

0 commit comments

Comments
 (0)