From 64cc7747c8b98e959f2a45a978583dd3d3d7e988 Mon Sep 17 00:00:00 2001 From: JRGTH Date: Tue, 13 Jul 2021 09:02:55 -0400 Subject: [PATCH] Disable colors if "NO_COLOR" env variable present --- usr/local/share/bastille/common.sh | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/usr/local/share/bastille/common.sh b/usr/local/share/bastille/common.sh index 4186519f..1220fb20 100644 --- a/usr/local/share/bastille/common.sh +++ b/usr/local/share/bastille/common.sh @@ -28,21 +28,19 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -. /usr/local/etc/bastille/bastille.conf +COLOR_RED= +COLOR_GREEN= +COLOR_YELLOW= +COLOR_RESET= -# Load text output colors if enabled in config -# else reset colors variables used by bastille -case "${bastille_colors_enable}" in - [Yy][Ee][Ss]) - . /usr/local/share/bastille/colors.pre.sh - ;; - *) - COLOR_RED= - COLOR_GREEN= - COLOR_YELLOW= - COLOR_RESET= - ;; -esac +enable_color() { + . /usr/local/share/bastille/colors.pre.sh +} + +# If "NO_COLOR" environment variable is present, disable output colors. +if ! export | grep -q "NO_COLOR"; then + enable_color +fi # Notify message on error, but do not exit error_notify() {