From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [iproute PATCH v2 4/4] lib: Enable colored output only for TTYs Date: Wed, 15 Aug 2018 12:30:57 -0700 Message-ID: <20180815123057.4e86f3be@xeon-e3> References: <20180815162127.21477-1-phil@nwl.cc> <20180815162127.21477-5-phil@nwl.cc> <06633975-40ae-f3d6-b5a9-8a947752e400@gmail.com> <20180815163944.GT32448@orbyte.nwl.cc> <0ce24184-cf62-5623-5a7c-b1b32ab8b1c3@gmail.com> <20180815165115.GU32448@orbyte.nwl.cc> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: David Ahern , netdev@vger.kernel.org, Till Maas To: Phil Sutter Return-path: Received: from mail-pg1-f194.google.com ([209.85.215.194]:34368 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbeHOWY3 (ORCPT ); Wed, 15 Aug 2018 18:24:29 -0400 Received: by mail-pg1-f194.google.com with SMTP id y5-v6so935768pgv.1 for ; Wed, 15 Aug 2018 12:31:01 -0700 (PDT) In-Reply-To: <20180815165115.GU32448@orbyte.nwl.cc> Sender: netdev-owner@vger.kernel.org List-ID: On Wed, 15 Aug 2018 18:51:15 +0200 Phil Sutter wrote: > On Wed, Aug 15, 2018 at 10:43:25AM -0600, David Ahern wrote: > > On 8/15/18 10:39 AM, Phil Sutter wrote: > > > On Wed, Aug 15, 2018 at 10:24:31AM -0600, David Ahern wrote: > > >> On 8/15/18 10:21 AM, Phil Sutter wrote: > > >>> Add an additional prerequisite to check_enable_color() to make sure > > >>> stdout actually points to an open TTY device. Otherwise calls like > > >>> > > >>> | ip -color a s >/tmp/foo > > >>> > > >>> will print color escape sequences into that file. Allow to override this > > >>> check by specifying '-color' flag more than once. > > >>> > > >>> Signed-off-by: Phil Sutter > > >>> --- > > >>> Changes since v1: > > >>> - Allow to override isatty() check by specifying '-color' flag more than > > >>> once. > > >> > > >> That adds overhead to my workflow where I almost always have to pipe the > > >> output of ip to a pager. > > > > > > alias ip='ip -color -color' > > > > no. Don't impact existing users. > > That's a possible fix for *your* workflow. If applied to the shell > handling that workflow, it won't impact existing users. > > > > Another alternative may be to introduce -autocolor flag. Establishing > > > the same syntax as used by 'ls' is not as trivial due to the simple > > > commandline parsing used in 'ip'. > > > > I disagree with ignoring or overriding an argument a user passes in. You > > are guessing what is the correct output and you are guessing wrong. > > There is nothing wrong with piping output to a file and the viewing that > > file through 'less -R'. > > > > If a user does not want the color codes in the file, then that user can > > drop the -color arg. iproute2 commands should not be guessing. > > OK, I got it. Should I respin the fixes or will you apply the series > partially? > > Thanks, Phil Please follow the color conventions of grep and ls to have consistent user experience. -c == --color=always and add never and auto.