From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15555 invoked from network); 29 May 2006 18:16:36 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.2 (2006-05-25) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.2 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 29 May 2006 18:16:36 -0000 Received: (qmail 92963 invoked from network); 29 May 2006 18:16:27 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 29 May 2006 18:16:27 -0000 Received: (qmail 16572 invoked by alias); 29 May 2006 18:16:20 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10345 Received: (qmail 16559 invoked from network); 29 May 2006 18:16:20 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 29 May 2006 18:16:20 -0000 Received: (qmail 91114 invoked from network); 29 May 2006 18:16:17 -0000 Received: from vms044pub.verizon.net (206.46.252.44) by a.mx.sunsite.dk with SMTP; 29 May 2006 18:16:12 -0000 Received: from torch.brasslantern.com ([71.116.105.50]) by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPA id <0J01003X3HEQ2AL0@vms044.mailsrvcs.net> for zsh-users@sunsite.dk; Mon, 29 May 2006 13:16:03 -0500 (CDT) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id k4TIG1fj001757 for ; Mon, 29 May 2006 11:16:02 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id k4TIG18A001756 for zsh-users@sunsite.dk; Mon, 29 May 2006 11:16:01 -0700 Date: Mon, 29 May 2006 11:16:01 -0700 From: Bart Schaefer Subject: De-script (Re: Vanishing files ?) In-reply-to: <20060529075722.GA28846@sci.fi> To: zsh-users@sunsite.dk Message-id: <060529111601.ZM1755@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <20060528.172405.74744323.Meino.Cramer@gmx.de> <060528113200.ZM31855@torch.brasslantern.com> <20060529075722.GA28846@sci.fi> Comments: In reply to Anssi Saari "Re: Vanishing files ?" (May 29, 10:57am) On May 29, 10:57am, Anssi Saari wrote: } } > } By the way: Does anyone know a trick how to remove _all_ } > } Escape-Sequences from a script generated by the command "script" ... } > } > sed "s/[^"$'\t '"-~]//g" } } That doesn't really work for escape sequences now does it? Ah, I see, I misinterpreted the original question. In order to strip entire terminal-control strings, you have to know what they are; which means in effect that you have to (a) read the termcap/terminfo database and (b) know the value of $TERM at the time the typescript was created. You could create something to do this using the perl Term::Cap and/or Term::Info modules, or in zsh with zsh/termcap and zsh/terminfo. The tricky bit is knowing which escapes use numeric counts or positions, so you can accept arbitrary digits at those locations. E.g. this is an UNTESTED example of what might work in zsh: function descript { ( # Subshell for parent terminal sanity emulate -R zsh typeset -A tpat TERM=${1:-$TERM} # Replace terminfo + echoti with termcap + echotc as needed for key in ${(k)terminfo} do [[ $terminfo[$key] == (yes|no) ]] && continue # Replace programmable digits with the <-> pattern. # If you have a 1000x1000 or larger terminal, I give up. tpat[$key]=${${(q)"$(echoti $key 998 998)"//$'\0'/}//99[89]/<->} # Debugging output: # print -u2 -R $key = ${(V)tpat[$key]} done pat=${(j:|:)tpat} # Run through "col" first to handle simple cursor movement col -bp | while read -r line do print -R -- ${line//(${~pat})/} done ) } Usage is e.g.: descript color-xterm < typescript Also realize that after you strip those, the result is no longer going to resemble what was visible on the screen during the creation of the typescript.