From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753687AbcGDMY0 (ORCPT ); Mon, 4 Jul 2016 08:24:26 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:35449 "EHLO relay6-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753076AbcGDMYZ (ORCPT ); Mon, 4 Jul 2016 08:24:25 -0400 X-Originating-IP: 50.39.163.18 Date: Mon, 4 Jul 2016 05:24:17 -0700 From: Josh Triplett To: Andrew Donnellan Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, valentinrothberg@gmail.com Subject: Re: checkkconfigsymbols.py: add --no-color option Message-ID: <20160704122415.GA7267@x> References: <1467621570-970-1-git-send-email-andrew.donnellan@au1.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1467621570-970-1-git-send-email-andrew.donnellan@au1.ibm.com> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Acked-by: Valentin Rothberg 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