commit: 15a828808106b943eea2e3b1c89705c51d91d4af Author: Kerin Millar <kfm <AT> plushkava <DOT> net> AuthorDate: Tue Jun 4 01:34:28 2024 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Wed Jun 12 07:06:42 2024 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=15a82880
Never print CHA sequences containing negative numbers in _eend() In cases where the value of genfun_tty is 2, render it impossible for _eend() ever to produce a CHA sequence that incorporates a negative column number. Some terminal emulators handle it sensibly whereas others do not. Signed-off-by: Kerin Millar <kfm <AT> plushkava.net> functions.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions.sh b/functions.sh index f5a59fc..409d424 100644 --- a/functions.sh +++ b/functions.sh @@ -773,7 +773,7 @@ yesno() # _eend() { - local efunc msg retval + local col efunc msg retval efunc=$1 shift @@ -815,7 +815,8 @@ _eend() # Save the cursor position with DECSC, move it up by one line # with CUU, position it horizontally with CHA, print the # indicator, then restore the cursor position with DECRC. - printf '\0337\033[1A\033[%dG %s\0338' "$(( genfun_cols - 6 + genfun_offset ))" "${msg}" + col=$(( genfun_cols > 6 ? genfun_cols - 6 : 1 )) + printf '\0337\033[1A\033[%dG %s\0338' "$(( col + genfun_offset ))" "${msg}" else # The standard output does not refer to a sufficiently capable # terminal. Print only the indicator.