[pacman-dev] [PATCH 1/2] makepkg: define escape sequences globally
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
Suggested-by: Dan McGee
Cedric Staniewski wrote:
Suggested-by: Dan McGee
Signed-off-by: Cedric Staniewski --- 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
Suggested-by: Dan McGee
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
---
<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
Allan 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
--- <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.
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
Suggested-by: Dan McGee
Cedric Staniewski wrote:
Suggested-by: Dan McGee
Signed-off-by: Cedric Staniewski --- 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
participants (2)
-
Allan McRae
-
Cedric Staniewski