From 7187dbe22405430c224e3848686cba170e182d93 Mon Sep 17 00:00:00 2001 From: merakor Date: Thu, 7 May 2020 17:30:34 +0000 Subject: kiss: change colour escape behaviour to be enabled and disabled. This adds the ability for globally enabling or disabling colour escapes. FossilOrigin-Name: 5640b4c4e6f28bcfe62dd0f476471042a24a633f44d57ccf5851cfa0e7761252 --- kiss | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kiss b/kiss index ebb20bc..b54556a 100755 --- a/kiss +++ b/kiss @@ -1426,9 +1426,6 @@ args() { log "Retrieving post-installation message queue" unset msg - [ "$KISS_COLOUR" ] || [ -t 1 ] && - colour=1 - for pkg in $order; do if [ -f "$sys_db/$pkg/message" ]; then printf '%s\n%b%s%b\n%s\n\n' \ @@ -1444,8 +1441,6 @@ args() { e|extension) log "Installed extensions" - [ "$KISS_COLOUR" ] || - [ -t 1 ] && colour=1 set -- @@ -1577,10 +1572,15 @@ main() { "${bin_dir:=$cac_dir/bin}" # Disable colour escape sequences if running in a subshell. - # This behaviour can be disabled by adding a KISS_COLOUR - # variable to the environment. - [ "$KISS_COLOUR" ] || [ -t 1 ] || + # This behaviour can be changed by adding a KISS_COLOUR + # variable to the environment. If it is set to 1 it will + # always enable colour escapes, and if set to 0 it will + # always disable colour escapes. + if [ "$KISS_COLOUR" = 1 ]; then colour=1 + elif [ "$KISS_COLOUR" = 0 ] || [ -t 0 ]; then log() { printf '%s %s %s\n' "${3:-->}" "$1" "$2" >&2 ;} + else colour=1 + fi args "$@" } -- cgit v1.2.3