From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2855 invoked from network); 16 Jun 2004 19:18:39 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.86) by ns1.primenet.com.au with SMTP; 16 Jun 2004 19:18:39 -0000 Received: (qmail 4105 invoked from network); 16 Jun 2004 19:18:20 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 16 Jun 2004 19:18:20 -0000 Received: (qmail 18289 invoked by alias); 16 Jun 2004 19:18:15 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20063 Received: (qmail 18280 invoked from network); 16 Jun 2004 19:18:15 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by sunsite.dk with SMTP; 16 Jun 2004 19:18:12 -0000 Received: (qmail 3725 invoked from network); 16 Jun 2004 19:18:07 -0000 Received: from 209-128-98-052.bayarea.net (HELO Yost.com) (209.128.98.52) by a.mx.sunsite.dk with SMTP; 16 Jun 2004 19:18:05 -0000 Received: from [192.168.1.2] (unknown [192.168.1.1]) by Yost.com (Postfix) with ESMTP id 9D3072381EE; Wed, 16 Jun 2004 12:17:50 -0700 (PDT) Mime-Version: 1.0 X-Sender: yost@ip4.yost.com Message-Id: Date: Wed, 16 Jun 2004 12:16:55 -0700 To: Peter Stephenson From: Dave Yost Subject: Re: zsh malloc bug Cc: zsh-workers@sunsite.dk Content-Type: text/plain; charset="us-ascii" X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=BAYES_50 autolearn=no version=2.63 X-Spam-Hits: 0.0 A real example follows. 1283 Z% touch ,x 1284 Z% echo ' import blah.*; ' | ./prepend ,x ,x.TMP-prepend-21041 zsh: done echo ' import '$package'.*; ' | zsh: bus error ./prepend ,x 1285 Z% ======= prepend #!/bin/zsh commandName=${0##*/} usage() { if [[ $1 != '' ]] ; then echo 1>&2 "\n$1" ; fi echo 1>&2 " Usage: $commandName [ -t ] file ... Prepends stdin to each of the given files. Reads stdin only once. The -t option preserves each file's modify time. " exit 2 } zparseopts -D -K - -help=argHelp v=argVerbose t=argPreserveMtime if [[ $#argHelp != 0 ]] ; then usage fi case $1 in -*) usage "Unknown option: $1" ;; esac #----------------------------------------- sourceTemp=/tmp/$commandName.$$ cat > $sourceTemp # I would have preferred this, but it discards trailing newlines: # source=`cat` TRAPINT() { echo 1>&2 "$commandName aborting: interrupted at file $file" rm -f $tmp exit 2 } TRAPEXIT() { rm -f $sourceTemp } for file in $* do if [[ -d $file ]] ; then echo 1>&2 "$commandName: skipping directory $file" else fileDir=${0%/*} fileName=${0##*/} tmp=$file.TMP-$commandName-$$ echo $tmp cat $sourceTemp > $tmp \ && cat $file >> $tmp if [[ $? != 0 ]] ; then echo 1>&2 "$commandName aborting: trouble at file $file" rm -f $tmp exit 2 else if [[ $#argPreserveMtime != 0 ]] ; then cpt -N $file $tmp fi mv -f $tmp $file if [[ $? != 0 ]] ; then echo 1>&2 "$commandName aborting: trouble at file $file" rm -f $tmp exit 2 fi if [[ $#argVerbose != 0 ]] ; then echo $file fi fi fi done