From e70c288225af9f511bba28b79e5e8f91af03b488 Mon Sep 17 00:00:00 2001 From: Tom Ice Date: Wed, 31 Mar 2021 10:33:25 -0400 Subject: [PATCH] Fix escape sequences when outputting to non-TTYs * When performing actions such as redirecting the stats to a file, the terminal escape sequences for handling colors gets added to the top message in the text file. While running commands such as sed can fix this, it is inconvenient for users wishing to redirect or pipe the stats in a clean way. Attempting to use test -t yielded some unexpected results, as well as extra logic for handling a non-tty case, so for now, we are simply removing the colors from the message so it defaults to standard terminal colors and formatting Fixes #122 --- git-quick-stats | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/git-quick-stats b/git-quick-stats index 1db2cca..fb360d2 100755 --- a/git-quick-stats +++ b/git-quick-stats @@ -224,12 +224,9 @@ showMenu() { # OUTS: None ################################################################################ function optionPicked() { - local -r bold=$(tput bold) - local -r red=$(tput setaf 1) - local -r reset=$(tput sgr0) - local msg=${*:-"${reset}Error: No message passed"} + local msg=${*:-"Error: No message passed"} - echo -e "${bold}${red}${msg}${reset}\n" + echo -e "${msg}\n" } ################################################################################