[pacman-dev] [PATCH] makepkg: use tput for terminal-safe colored and bold text

Cedric Staniewski cedric at gmx.ca
Thu Oct 22 15:08:52 EDT 2009


Suggested-by: Dan McGee <dan at archlinux.org>
Signed-off-by: Cedric Staniewski <cedric at gmx.ca>
---

I do not know if this patch is usefull at all, because I do not notice any
change. Just grabbed this from Dan's TODO list and wanted to play a bit
with tput.


scripts/makepkg.sh.in |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 40367ae..a64a867 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -85,7 +85,7 @@ PACMAN_OPTS=
 plain() {
 	local mesg=$1; shift
 	if [ $COLORMSG -eq 1 ]; then
-		printf "\033[1;1m    ${mesg}\033[1;0m\n" "$@" >&2
+		printf "$(tput bold)    ${mesg}$(tput sgr0)\n" "$@" >&2
 	else
 		printf "    ${mesg}\n" "$@" >&2
 	fi
@@ -94,7 +94,7 @@ plain() {
 msg() {
 	local mesg=$1; shift
 	if [ $COLORMSG -eq 1 ]; then
-		printf "\033[1;32m==>\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
+		printf "$(echo -e "bold\nsetaf 2" | tput -S)==>$(echo -e "sgr0\nbold" | tput -S) ${mesg}$(tput sgr0)\n" "$@" >&2
 	else
 		printf "==> ${mesg}\n" "$@" >&2
 	fi
@@ -103,7 +103,7 @@ msg() {
 msg2() {
 	local mesg=$1; shift
 	if [ $COLORMSG -eq 1 ]; then
-		printf "\033[1;34m  ->\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
+		printf "$(echo -e "bold\nsetaf 4" | tput -S)  ->$(echo -e "sgr0\nbold" | tput -S) ${mesg}$(tput sgr0)\n" "$@" >&2
 	else
 		printf "  -> ${mesg}\n" "$@" >&2
 	fi
@@ -112,7 +112,7 @@ msg2() {
 warning() {
 	local mesg=$1; shift
 	if [ $COLORMSG -eq 1 ]; then
-		printf "\033[1;33m==> $(gettext "WARNING:")\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
+		printf "$(echo -e "bold\nsetaf 3" | tput -S)==> $(gettext "WARNING:")$(echo -e "sgr0\nbold" | tput -S) ${mesg}$(tput sgr0)\n" "$@" >&2
 	else
 		printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2
 	fi
@@ -121,7 +121,7 @@ warning() {
 error() {
 	local mesg=$1; shift
 	if [ $COLORMSG -eq 1 ]; then
-		printf "\033[1;31m==> $(gettext "ERROR:")\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
+		printf "$(echo -e "bold\nsetaf 1" | tput -S)==> $(gettext "ERROR:")$(echo -e "sgr0\nbold" | tput -S) ${mesg}$(tput sgr0)\n" "$@" >&2
 	else
 		printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2
 	fi
-- 
1.6.5.1



More information about the pacman-dev mailing list