summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKerin Millar <kfm@plushkava.net>2023-06-09 22:21:35 +0100
committerKerin Millar <kfm@plushkava.net>2023-06-09 22:21:51 +0100
commit721c22bcd300b9a5d995e3dfbe66e46ca944e08d (patch)
tree64351dc75cba85ca44769a06aedce4e89f179d17
parentHave ecma48-cpr flush the terminal's input queue (diff)
downloadgentoo-functions-721c22bcd300b9a5d995e3dfbe66e46ca944e08d.tar.gz
gentoo-functions-721c22bcd300b9a5d995e3dfbe66e46ca944e08d.tar.bz2
gentoo-functions-721c22bcd300b9a5d995e3dfbe66e46ca944e08d.zip
Right-trim messages given to ebegin() and _eprint() where appropriate
Have ebegin() strip all trailing newlines rather than just one at most. Likewise for _eprint() in the case that a smart terminal is found. Signed-off-by: Kerin Millar <kfm@plushkava.net>
-rw-r--r--functions.sh.in16
1 files changed, 12 insertions, 4 deletions
diff --git a/functions.sh.in b/functions.sh.in
index 673be7d..5141670 100644
--- a/functions.sh.in
+++ b/functions.sh.in
@@ -62,8 +62,13 @@ _eprint() {
# VT100 and can be considered as a de-facto standard.
printf ' %s*%s %s%s\0337' "${color}" "${NORMAL}" "${genfun_indent}" "${msg}"
else
- # Print the message without its trailing LF character.
- msg=${msg%"${genfun_newline}"}
+ # Strip all trailing LF characters before printing the message.
+ while true; do
+ msg=${msg%"${genfun_newline}"}
+ if ! _ends_with_newline "${msg}"; then
+ break
+ fi
+ done
printf ' %s*%s %s%s' "${color}" "${NORMAL}" "${genfun_indent}" "${msg}"
# Determine the current position of the cursor
@@ -235,7 +240,9 @@ ebegin()
if ! yesno "${EINFO_QUIET}"; then
msg=$*
- msg=${msg%"${genfun_newline}"}
+ while _ends_with_newline "${msg}"; do
+ msg=${msg%"${genfun_newline}"}
+ done
_eprint "${GOOD}" "${msg} ..."
fi
}
@@ -584,7 +591,8 @@ _has_monochrome_terminal() {
}
_ends_with_newline() {
- ! case $1 in *"${genfun_newline}") false ;; esac
+ test "${genfun_newline}" \
+ && ! case $1 in *"${genfun_newline}") false ;; esac
}
_update_tty_level() {