From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25936 invoked by alias); 16 May 2011 11:03:56 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 16031 Received: (qmail 3170 invoked from network); 16 May 2011 11:03:53 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at m.gmane.org designates 80.91.229.12 as permitted sender) X-Injected-Via-Gmane: http://gmane.org/ To: zsh-users@zsh.org From: Thorsten Kampe Subject: Re: How to redirect output without escape sequences to a file Date: Mon, 16 May 2011 13:03:14 +0200 Message-ID: References: <110509080130.ZM19360@torch.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: nat.scz.novell.com User-Agent: MicroPlanet-Gravity/3.0.4 * Bart Schaefer (Mon, 09 May 2011 08:01:30 -0700) > On May 8, 9:27pm, Thorsten Kampe wrote: > } I've modified my PS4 so it contains a little bit of colour[1]. > > I was going to suggest that you stop using the terminal escape > sequences directly and use the %F prompt escape instead: > > PS4='%F{cyan}%B+%b%f%1N[%i]%F{cyan}%B:%b%f ' > > Theoretically, these are only supposed to be output if the terminal > supports them, so I thought that setting TERM=dumb would then turn > off the coloring. But no ... zsh goes for ANSI sequences if the > terminal definition doesn't specify, so something is always output. > > } Is there a way to either strip the escape sequences when redirected to > } a file or to modify PS4 when stderr is redirected to a file? > > So, the alternative is to do the stripping. Instead of > > ... >& trace.log > > use > > ... 2>>(col > trace.log) >&2 > > Yes, that's somewhat inconvenient. ...and somehow not working (form me). I still got (stripped) color stuff in the output file ("1m33m-0m39m service:directory-agent" for instance). "| sed 's/\x1b\[[0-9]\{1,2\}m//g'" worked for me. How would the command line look like if wanted to pipe stdout and stderr to sed, and then redirect both to trace.log? Thorsten