From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7317 invoked from network); 7 Dec 2000 13:58:16 -0000 Received: from sunsite.dk (HELO sunsite.auc.dk) (130.225.51.30) by ns1.primenet.com.au with SMTP; 7 Dec 2000 13:58:16 -0000 Received: (qmail 3584 invoked by alias); 7 Dec 2000 13:57:52 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3554 Received: (qmail 3577 invoked from network); 7 Dec 2000 13:57:50 -0000 Date: 7 Dec 2000 11:44:47 -0000 Message-Id: Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Content-Disposition: inline From: nirva@ishiboo.com (Danny Dulai) To: azure@iki.fi (Hannu Koivisto), zsh-users@sunsite.auc.dk (Zsh Users' List) Subject: Re: Better ( rm foo; bar > foo ) < foo ? X-Mailer: Liam [version 0.7] In-Reply-To: <87n1edeh8c.fsf@senstation.vvf.fi> On 12/03/00, Hannu Koivisto said: >Greetings, > >If I needed to, say, modify some file with sed in a script, I'd >probably write something like this: > >TMPFILE=3D$(mktemp "$(dirname "$FILE")/XXXXXX") || exit 1 >sed 's/foo/bar/g' < "$FILE" > "$TMPFILE" || { rm -f "$TMPFILE" ; exit 1= } >mv "$TMPFILE" "$FILE" > >This is quite clumsy (even if I removed some of the safety) and >thus the trick shown on the subject is quite appealing especially >in interactive use. Unfortunately it has the problem that if bar >fails, the data is lost. Besides, even it is a bit clumsier than >I'd like. > >So, I started to ponder if zsh could help here. Unfortunately I >couldn't come up with any nice "wrapping" of the functionality >above with a function or other existing zsh features, only a >thought of whether it would be possible to create some sort of new >redirection syntax that would do the trick. > >What do you think? > >--=20 >Hannu > % cat foo one % mv =3D(sed 's/one/two/' foo) foo % cat foo two hows that? --=20 ___________________________________________________________________________ Danny Dulai Feet. Pumice. Lotion. http://www.ishiboo.com/~nirva/ nirva@ishiboo.com