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

Allan McRae allan at archlinux.org
Sat Oct 24 09:31:39 EDT 2009


Cedric Staniewski wrote:
> Suggested-by: Dan McGee <dan at archlinux.org>
> Signed-off-by: Cedric Staniewski <cedric at gmx.ca>
> ---
>  scripts/makepkg.sh.in |   14 +++++++-------
>  1 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index d427f15..bdc51eb 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -28,7 +28,7 @@
>  # makepkg uses quite a few external programs during its execution. You
>  # need to have at least the following installed for makepkg to function:
>  #   bsdtar (libarchive), bzip2, coreutils, fakeroot, find (findutils),
> -#   getopt (util-linux), gettext, grep, gzip, openssl, sed
> +#   getopt (util-linux), gettext, grep, gzip, openssl, sed, tput (ncurses)
>  
>  # gettext initialization
>  export TEXTDOMAIN='pacman'
> @@ -1557,12 +1557,12 @@ unset ALL_OFF BOLD BLUE GREEN RED YELLOW
>  
>  # check if messages are to be printed using color
>  if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
> -	ALL_OFF="\033[1;0m"
> -	BOLD="\033[1;1m"
> -	BLUE="${BOLD}\033[1;34m"
> -	GREEN="${BOLD}\033[1;32m"
> -	RED="${BOLD}\033[1;31m"
> -	YELLOW="${BOLD}\033[1;33m"
> +	ALL_OFF="$(tput sgr0)"
> +	BOLD="$(tput bold)"
> +	BLUE="${BOLD}$(tput setaf 4)"
> +	GREEN="${BOLD}$(tput setaf 2)"
> +	RED="${BOLD}$(tput setaf 1)"
> +	YELLOW="${BOLD}$(tput setaf 3)"
>  fi
>  
>  readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
>   

Great.   Applied both these patches to my working branch (with minor 
formatting change at apply on to of other patches I have there).

Allan



More information about the pacman-dev mailing list