2
0
mirror of https://github.com/mozilla/cipherscan.git synced 2024-12-26 12:43:42 +01:00

autodetect if the colors should be used

check if the terminal output doesn't go to a pipe (less, file, etc.)
don't output colors by default then
This commit is contained in:
Hubert Kario 2015-09-19 16:16:11 +02:00
parent 460f9cf1f6
commit bb2d3223f8

View File

@ -197,7 +197,7 @@ DELAY=0
ALLCIPHERS=""
OUTPUTFORMAT="terminal"
TIMEOUT=30
USECOLORS="True"
USECOLORS="auto"
# place where to put the found intermediate CA certificates and where
# trust anchors are stored
SAVECRT=""
@ -250,6 +250,7 @@ Use one of the options below:
--[no-]curves test ECC curves supported by server (req. OpenSSL 1.0.2)
--[no-]tolerance test TLS tolerance
--no-sni don't use Server Name Indication
--colors force use of colors (autodetect by default)
--no-colors don't use terminal colors
-v | --verbose Increase verbosity.
@ -690,7 +691,14 @@ display_results_in_terminal() {
local curvesordering
local different=False
# Configure colors, if terminal supports them
if [[ $USECOLORS == "True" && -x /usr/bin/tput ]] && tput setaf 1 >&/dev/null; then
if [[ $USECOLORS == "auto" ]]; then
if [[ -t 1 ]]; then
USECOLORS="True"
else
USECOLORS="False"
fi
fi
if [[ $USECOLORS == "True" ]]; then
c_blue="\033[0;34m"
c_green="\033[0;32m"
c_red="\033[0;31m"
@ -1422,6 +1430,10 @@ do
TEST_TOLERANCE="False"
shift 1
;;
--colors)
USECOLORS="True"
shift 1
;;
--no-colors)
USECOLORS="False"
shift 1