From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 4BD321581E0 for ; Sat, 10 Jun 2023 04:22:05 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8AAC1E093D; Sat, 10 Jun 2023 04:22:04 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 69FA2E093D for ; Sat, 10 Jun 2023 04:22:04 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7E810335D83 for ; Sat, 10 Jun 2023 04:22:03 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 1EC98A8E for ; Sat, 10 Jun 2023 04:22:02 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1686345711.721c22bcd300b9a5d995e3dfbe66e46ca944e08d.sam@gentoo> Subject: [gentoo-commits] proj/gentoo-functions:master commit in: / X-VCS-Repository: proj/gentoo-functions X-VCS-Files: functions.sh.in X-VCS-Directories: / X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 721c22bcd300b9a5d995e3dfbe66e46ca944e08d X-VCS-Branch: master Date: Sat, 10 Jun 2023 04:22:02 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 5bda609e-5de6-4e92-9853-c54f520eba86 X-Archives-Hash: 1de04277feaae57e4c72f0d05c2f149a commit: 721c22bcd300b9a5d995e3dfbe66e46ca944e08d Author: Kerin Millar plushkava net> AuthorDate: Fri Jun 9 21:21:35 2023 +0000 Commit: Sam James gentoo org> CommitDate: Fri Jun 9 21:21:51 2023 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=721c22bc 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 plushkava.net> functions.sh.in | 16 ++++++++++++---- 1 file 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() {