From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11545 invoked from network); 3 Dec 2000 14:42:03 -0000 Received: from sunsite.dk (HELO sunsite.auc.dk) (130.225.51.30) by ns1.primenet.com.au with SMTP; 3 Dec 2000 14:42:03 -0000 Received: (qmail 18828 invoked by alias); 3 Dec 2000 14:41:39 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3542 Received: (qmail 18820 invoked from network); 3 Dec 2000 14:41:37 -0000 To: Zsh Users' List Subject: Better ( rm foo; bar > foo ) < foo ? Mail-Followup-To: zsh-users@sunsite.auc.dk From: Hannu Koivisto Date: 03 Dec 2000 16:01:39 +0200 Message-ID: <87n1edeh8c.fsf@senstation.vvf.fi> User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: Hannu Koivisto Greetings, If I needed to, say, modify some file with sed in a script, I'd probably write something like this: TMPFILE=$(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? -- Hannu