mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
Refactor testing for color message output
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
7df0d048d1
commit
7a8ba5a978
@ -69,6 +69,7 @@ IGNOREARCH=0
|
|||||||
HOLDVER=0
|
HOLDVER=0
|
||||||
PKGFUNC=0
|
PKGFUNC=0
|
||||||
SPLITPKG=0
|
SPLITPKG=0
|
||||||
|
COLORMSG=0
|
||||||
|
|
||||||
# Forces the pkgver of the current PKGBUILD. Used by the fakeroot call
|
# Forces the pkgver of the current PKGBUILD. Used by the fakeroot call
|
||||||
# when dealing with svn/cvs/etc PKGBUILDs.
|
# when dealing with svn/cvs/etc PKGBUILDs.
|
||||||
@ -80,7 +81,7 @@ PACMAN_OPTS=
|
|||||||
|
|
||||||
plain() {
|
plain() {
|
||||||
local mesg=$1; shift
|
local mesg=$1; shift
|
||||||
if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
if [ $COLORMSG -eq 1 ]; then
|
||||||
printf "\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
printf "\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
||||||
else
|
else
|
||||||
printf " ${mesg}\n" "$@" >&2
|
printf " ${mesg}\n" "$@" >&2
|
||||||
@ -89,7 +90,7 @@ plain() {
|
|||||||
|
|
||||||
msg() {
|
msg() {
|
||||||
local mesg=$1; shift
|
local mesg=$1; shift
|
||||||
if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
if [ $COLORMSG -eq 1 ]; then
|
||||||
printf "\033[1;32m==>\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
printf "\033[1;32m==>\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
||||||
else
|
else
|
||||||
printf "==> ${mesg}\n" "$@" >&2
|
printf "==> ${mesg}\n" "$@" >&2
|
||||||
@ -98,7 +99,7 @@ msg() {
|
|||||||
|
|
||||||
msg2() {
|
msg2() {
|
||||||
local mesg=$1; shift
|
local mesg=$1; shift
|
||||||
if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
if [ $COLORMSG -eq 1 ]; then
|
||||||
printf "\033[1;34m ->\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
printf "\033[1;34m ->\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
||||||
else
|
else
|
||||||
printf " -> ${mesg}\n" "$@" >&2
|
printf " -> ${mesg}\n" "$@" >&2
|
||||||
@ -107,7 +108,7 @@ msg2() {
|
|||||||
|
|
||||||
warning() {
|
warning() {
|
||||||
local mesg=$1; shift
|
local mesg=$1; shift
|
||||||
if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
if [ $COLORMSG -eq 1 ]; then
|
||||||
printf "\033[1;33m==> $(gettext "WARNING:")\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
printf "\033[1;33m==> $(gettext "WARNING:")\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
||||||
else
|
else
|
||||||
printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2
|
printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2
|
||||||
@ -116,7 +117,7 @@ warning() {
|
|||||||
|
|
||||||
error() {
|
error() {
|
||||||
local mesg=$1; shift
|
local mesg=$1; shift
|
||||||
if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
if [ $COLORMSG -eq 1 ]; then
|
||||||
printf "\033[1;31m==> $(gettext "ERROR:")\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
printf "\033[1;31m==> $(gettext "ERROR:")\033[1;0m\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2
|
||||||
else
|
else
|
||||||
printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2
|
printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2
|
||||||
@ -1382,6 +1383,11 @@ if [ -r ~/.makepkg.conf ]; then
|
|||||||
source ~/.makepkg.conf
|
source ~/.makepkg.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# check if messages are to be printed using color
|
||||||
|
if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then
|
||||||
|
COLORMSG=1
|
||||||
|
fi
|
||||||
|
|
||||||
# override settings with an environment variable for batch processing
|
# override settings with an environment variable for batch processing
|
||||||
PKGDEST=${_PKGDEST:-$PKGDEST}
|
PKGDEST=${_PKGDEST:-$PKGDEST}
|
||||||
PKGDEST=${PKGDEST:-$startdir} #default to $startdir if undefined
|
PKGDEST=${PKGDEST:-$startdir} #default to $startdir if undefined
|
||||||
|
Loading…
Reference in New Issue
Block a user