From: Phil Sutter Subject: Re: [iproute PATCH v2 4/4] lib: Enable colored output only for TTYs Date: Wed, 15 Aug 2018 18:39:44 +0200 Message-ID: <20180815163944.GT32448@orbyte.nwl.cc> References: <20180815162127.21477-1-phil@nwl.cc> <20180815162127.21477-5-phil@nwl.cc> <06633975-40ae-f3d6-b5a9-8a947752e400@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Stephen Hemminger , netdev@vger.kernel.org, Till Maas To: David Ahern Return-path: Received: from orbyte.nwl.cc ([151.80.46.58]:41190 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729464AbeHOTcj (ORCPT ); Wed, 15 Aug 2018 15:32:39 -0400 Content-Disposition: inline In-Reply-To: <06633975-40ae-f3d6-b5a9-8a947752e400@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: 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' 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'. Cheers, Phil