diff options
author | Ulrich Müller <ulm@gentoo.org> | 2017-09-23 20:38:29 +0200 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2022-07-30 06:46:33 +0100 |
commit | 44c2ebb24e53bbf8c8848072cbe3b66471f883df (patch) | |
tree | 1dd4aff21afed86466db67ade092718691da9ead | |
parent | functions.sh: use consistent Gentoo style for braces (diff) | |
download | gentoo-functions-44c2ebb24e53bbf8c8848072cbe3b66471f883df.tar.gz gentoo-functions-44c2ebb24e53bbf8c8848072cbe3b66471f883df.tar.bz2 gentoo-functions-44c2ebb24e53bbf8c8848072cbe3b66471f883df.zip |
functions.sh: Don't hardcode escape seqences for ENDCOL0.17
Similar to handling of colors, this should make use of tput,
rather than sending unknown escape sequences to dumb terminals.
Bug: https://bugs.gentoo.org/631870
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r-- | functions.sh | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/functions.sh b/functions.sh index a5f3bfd..acce989 100644 --- a/functions.sh +++ b/functions.sh @@ -429,10 +429,12 @@ COLS="${COLUMNS:-0}" # bash's internal COLUMNS variable [ -z "${COLS}" ] && COLS=80 [ "${COLS}" -gt 0 ] || COLS=80 # width of [ ok ] == 7 -if yesno "${RC_ENDCOL}"; then - ENDCOL='\033[A\033['$(( COLS - 8 ))'C' -else +if ! yesno "${RC_ENDCOL}"; then ENDCOL='' +elif command -v tput >/dev/null 2>&1; then + ENDCOL="$(tput cuu1)$(tput cuf $(( COLS - 8 )) )" +else + ENDCOL='\033[A\033['$(( COLS - 8 ))'C' fi # Setup the colors so our messages all look pretty |