|
View:
New views
9 Messages
—
Rating Filter:
Alert me
|
|
|
[PATCH 1/2] makepkg: define escape sequences globallyIn doing so, it is possible to get rid of all the tests for colored
messages except for one global one. Signed-off-by: Cedric Staniewski <cedric@...> --- scripts/makepkg.sh.in | 42 +++++++++++++++--------------------------- 1 files changed, 15 insertions(+), 27 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 40367ae..2a3d22d 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -72,7 +72,6 @@ IGNOREARCH=0 HOLDVER=0 PKGFUNC=0 SPLITPKG=0 -COLORMSG=0 # Forces the pkgver of the current PKGBUILD. Used by the fakeroot call # when dealing with svn/cvs/etc PKGBUILDs. @@ -84,47 +83,27 @@ PACMAN_OPTS= plain() { local mesg=$1; shift - if [ $COLORMSG -eq 1 ]; then - printf "\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2 - else - printf " ${mesg}\n" "$@" >&2 - fi + printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } 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 - else - printf "==> ${mesg}\n" "$@" >&2 - fi + printf "${GREEN}==>${ALL_OFF_BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } 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 - else - printf " -> ${mesg}\n" "$@" >&2 - fi + printf "${BLUE} ->${ALL_OFF_BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } 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 - else - printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2 - fi + printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF_BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } 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 - else - printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2 - fi + printf "${RED}==> $(gettext "ERROR:")${ALL_OFF_BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } @@ -1576,7 +1555,16 @@ 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 + readonly ALL_OFF="\033[1;0m" \ + BOLD="\033[1;1m" + readonly ALL_OFF_BOLD="${ALL_OFF}${BOLD}" \ + RED="${BOLD}\033[1;31m" \ + BLUE="${BOLD}\033[1;34m" \ + GREEN="${BOLD}\033[1;32m" \ + YELLOW="${BOLD}\033[1;33m" +else + unset ALL_OFF ALL_OFF_BOLD BOLD RED BLUE GREEN YELLOW + readonly ALL_OFF ALL_OFF_BOLD BOLD RED BLUE GREEN YELLOW fi # override settings with an environment variable for batch processing -- 1.6.5.1 |
|
|
[PATCH 2/2] makepkg: use tput for terminal-safe colored and bold textSuggested-by: Dan McGee <dan@...>
Signed-off-by: Cedric Staniewski <cedric@...> --- Does by chance anybody know if it is possible to build readline without ncurses? If so, we should add tput (ncurses) dependency to the header. scripts/makepkg.sh.in | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 2a3d22d..b89acdb 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1555,13 +1555,13 @@ fi # check if messages are to be printed using color if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then - readonly ALL_OFF="\033[1;0m" \ - BOLD="\033[1;1m" + readonly ALL_OFF="$(tput sgr0)" \ + BOLD="$(tput bold)" readonly ALL_OFF_BOLD="${ALL_OFF}${BOLD}" \ - RED="${BOLD}\033[1;31m" \ - BLUE="${BOLD}\033[1;34m" \ - GREEN="${BOLD}\033[1;32m" \ - YELLOW="${BOLD}\033[1;33m" + RED="${BOLD}$(tput setaf 1)" \ + BLUE="${BOLD}$(tput setaf 4)" \ + GREEN="${BOLD}$(tput setaf 2)" \ + YELLOW="${BOLD}$(tput setaf 3)" else unset ALL_OFF ALL_OFF_BOLD BOLD RED BLUE GREEN YELLOW readonly ALL_OFF ALL_OFF_BOLD BOLD RED BLUE GREEN YELLOW -- 1.6.5.1 |
|
|
Re: [PATCH 2/2] makepkg: use tput for terminal-safe colored and bold textCedric Staniewski wrote:
> Suggested-by: Dan McGee <dan@...> > Signed-off-by: Cedric Staniewski <cedric@...> > --- > > Does by chance anybody know if it is possible to build readline without ncurses? If so, we should add tput (ncurses) dependency to the header. I do not think it is possible given the need to bootstrap readline and bash for ncurses soname bumps. Then again, maybe I have never tried... It is probably best to add that to the header anyway for completeness. Allan |
|
|
[PATCH] makepkg: use tput for terminal-safe colored and bold textSuggested-by: Dan McGee <dan@...>
Signed-off-by: Cedric Staniewski <cedric@...> --- 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 2a3d22d..f7d1fc8 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' @@ -1555,13 +1555,13 @@ fi # check if messages are to be printed using color if [ -t 2 -a ! "$USE_COLOR" = "n" -a "$(check_buildenv color)" = "y" ]; then - readonly ALL_OFF="\033[1;0m" \ - BOLD="\033[1;1m" + readonly ALL_OFF="$(tput sgr0)" \ + BOLD="$(tput bold)" readonly ALL_OFF_BOLD="${ALL_OFF}${BOLD}" \ - RED="${BOLD}\033[1;31m" \ - BLUE="${BOLD}\033[1;34m" \ - GREEN="${BOLD}\033[1;32m" \ - YELLOW="${BOLD}\033[1;33m" + RED="${BOLD}$(tput setaf 1)" \ + BLUE="${BOLD}$(tput setaf 4)" \ + GREEN="${BOLD}$(tput setaf 2)" \ + YELLOW="${BOLD}$(tput setaf 3)" else unset ALL_OFF ALL_OFF_BOLD BOLD RED BLUE GREEN YELLOW readonly ALL_OFF ALL_OFF_BOLD BOLD RED BLUE GREEN YELLOW -- 1.6.5.1 |
|
|
Re: [PATCH 1/2] makepkg: define escape sequences globallyCedric Staniewski wrote:
> In doing so, it is possible to get rid of all the tests for colored > messages except for one global one. > > Signed-off-by: Cedric Staniewski <cedric@...> > --- > <snip> > > @@ -1576,7 +1555,16 @@ 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 > + readonly ALL_OFF="\033[1;0m" \ > + BOLD="\033[1;1m" > + readonly ALL_OFF_BOLD="${ALL_OFF}${BOLD}" \ > + RED="${BOLD}\033[1;31m" \ > + BLUE="${BOLD}\033[1;34m" \ > + GREEN="${BOLD}\033[1;32m" \ > + YELLOW="${BOLD}\033[1;33m" > +else > + unset ALL_OFF ALL_OFF_BOLD BOLD RED BLUE GREEN YELLOW > + readonly ALL_OFF ALL_OFF_BOLD BOLD RED BLUE GREEN YELLOW > fi > > # override settings with an environment variable for batch processing > How about a slight change here: if [ .... ]; then ALL_OFF= BOLD= ... else unset .... fi readonly ... That cleans up that first part of the if statement somewhat. I am also not sure about the need for ${ALL_OFF_BOLD} given it is only two less characters that ${ALL_OFF}${BOLD} and that way seems to be clearer to me. Allan |
|
|
Re: [PATCH 1/2] makepkg: define escape sequences globallyAllan McRae wrote:
> Cedric Staniewski wrote: >> In doing so, it is possible to get rid of all the tests for colored >> messages except for one global one. >> >> Signed-off-by: Cedric Staniewski <cedric@...> >> --- > >> <snip> > >> >> @@ -1576,7 +1555,16 @@ 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 >> + readonly ALL_OFF="\033[1;0m" \ >> + BOLD="\033[1;1m" >> + readonly ALL_OFF_BOLD="${ALL_OFF}${BOLD}" \ >> + RED="${BOLD}\033[1;31m" \ >> + BLUE="${BOLD}\033[1;34m" \ >> + GREEN="${BOLD}\033[1;32m" \ >> + YELLOW="${BOLD}\033[1;33m" >> +else >> + unset ALL_OFF ALL_OFF_BOLD BOLD RED BLUE GREEN YELLOW >> + readonly ALL_OFF ALL_OFF_BOLD BOLD RED BLUE GREEN YELLOW >> fi >> >> # override settings with an environment variable for batch processing >> > > How about a slight change here: > > if [ .... ]; then > ALL_OFF= > BOLD= > ... > else > unset .... > fi > readonly ... > > That cleans up that first part of the if statement somewhat. > > I am also not sure about the need for ${ALL_OFF_BOLD} given it is only > two less characters that ${ALL_OFF}${BOLD} and that way seems to be > clearer to me. > > Allan That looks much nicer indeed. Thanks for the hint. |
|
|
[PATCH 1/2] makepkg: define escape sequences globallyIn doing so, it is possible to get rid of all the tests for colored
messages except for one global one. Signed-off-by: Cedric Staniewski <cedric@...> --- scripts/makepkg.sh.in | 42 +++++++++++++++--------------------------- 1 files changed, 15 insertions(+), 27 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 40367ae..d427f15 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -72,7 +72,6 @@ IGNOREARCH=0 HOLDVER=0 PKGFUNC=0 SPLITPKG=0 -COLORMSG=0 # Forces the pkgver of the current PKGBUILD. Used by the fakeroot call # when dealing with svn/cvs/etc PKGBUILDs. @@ -84,47 +83,27 @@ PACMAN_OPTS= plain() { local mesg=$1; shift - if [ $COLORMSG -eq 1 ]; then - printf "\033[1;1m ${mesg}\033[1;0m\n" "$@" >&2 - else - printf " ${mesg}\n" "$@" >&2 - fi + printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } 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 - else - printf "==> ${mesg}\n" "$@" >&2 - fi + printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } 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 - else - printf " -> ${mesg}\n" "$@" >&2 - fi + printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } 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 - else - printf "==> $(gettext "WARNING:") ${mesg}\n" "$@" >&2 - fi + printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } 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 - else - printf "==> $(gettext "ERROR:") ${mesg}\n" "$@" >&2 - fi + printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 } @@ -1574,11 +1553,20 @@ if [ -r ~/.makepkg.conf ]; then source ~/.makepkg.conf fi +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 - COLORMSG=1 + 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" fi +readonly ALL_OFF BOLD BLUE GREEN RED YELLOW + # override settings with an environment variable for batch processing PKGDEST=${_PKGDEST:-$PKGDEST} PKGDEST=${PKGDEST:-$startdir} #default to $startdir if undefined -- 1.6.5.1 |
|
|
[PATCH 2/2] makepkg: use tput for terminal-safe colored and bold textSuggested-by: Dan McGee <dan@...>
Signed-off-by: Cedric Staniewski <cedric@...> --- 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 -- 1.6.5.1 |
|
|
Re: [PATCH 2/2] makepkg: use tput for terminal-safe colored and bold textCedric Staniewski wrote:
> Suggested-by: Dan McGee <dan@...> > Signed-off-by: Cedric Staniewski <cedric@...> > --- > 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 |
| Free embeddable forum powered by Nabble | Forum Help |