1 |
commit: 44c2ebb24e53bbf8c8848072cbe3b66471f883df |
2 |
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Sep 23 18:38:29 2017 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Jul 30 05:46:33 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=44c2ebb2 |
7 |
|
8 |
functions.sh: Don't hardcode escape seqences for ENDCOL |
9 |
|
10 |
Similar to handling of colors, this should make use of tput, |
11 |
rather than sending unknown escape sequences to dumb terminals. |
12 |
|
13 |
Bug: https://bugs.gentoo.org/631870 |
14 |
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org> |
15 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
16 |
|
17 |
functions.sh | 8 +++++--- |
18 |
1 file changed, 5 insertions(+), 3 deletions(-) |
19 |
|
20 |
diff --git a/functions.sh b/functions.sh |
21 |
index a5f3bfd..acce989 100644 |
22 |
--- a/functions.sh |
23 |
+++ b/functions.sh |
24 |
@@ -429,10 +429,12 @@ COLS="${COLUMNS:-0}" # bash's internal COLUMNS variable |
25 |
[ -z "${COLS}" ] && COLS=80 |
26 |
[ "${COLS}" -gt 0 ] || COLS=80 # width of [ ok ] == 7 |
27 |
|
28 |
-if yesno "${RC_ENDCOL}"; then |
29 |
- ENDCOL='\033[A\033['$(( COLS - 8 ))'C' |
30 |
-else |
31 |
+if ! yesno "${RC_ENDCOL}"; then |
32 |
ENDCOL='' |
33 |
+elif command -v tput >/dev/null 2>&1; then |
34 |
+ ENDCOL="$(tput cuu1)$(tput cuf $(( COLS - 8 )) )" |
35 |
+else |
36 |
+ ENDCOL='\033[A\033['$(( COLS - 8 ))'C' |
37 |
fi |
38 |
|
39 |
# Setup the colors so our messages all look pretty |