[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160704122415.GA7267@x>
Date: Mon, 4 Jul 2016 05:24:17 -0700
From: Josh Triplett <josh@...htriplett.org>
To: Andrew Donnellan <andrew.donnellan@....ibm.com>
Cc: linux-kernel@...r.kernel.org, gregkh@...uxfoundation.org,
valentinrothberg@...il.com
Subject: Re: checkkconfigsymbols.py: add --no-color option
On Mon, Jul 04, 2016 at 06:39:30PM +1000, Andrew Donnellan wrote:
> Add a new option, --no-color, to get rid of ANSI colour escape codes in the
> output. Useful if redirecting output to a file or piping to another script.
>
> (It should really be --no-colour, but I'll accept US spelling in the name
> of consistency with existing usage in the code comments...)
>
> Signed-off-by: Andrew Donnellan <andrew.donnellan@....ibm.com>
> Acked-by: Valentin Rothberg <valentinrothberg@...il.com>
Rather than requiring an explicit option, how about detecting
whether stdout is a TTY and automatically suppressing color?
You could check "os.isatty(1)" in main(), and set a global "color =
False". That would automatically handle the cases of redirecting to a
file or piping to another script, without requiring the user to pass
--no-color.
- Josh Triplett
Powered by blists - more mailing lists