zsh-users
 help / color / mirror / code / Atom feed
* Better ( rm foo; bar > foo ) < foo ?
@ 2000-12-03 14:01 Hannu Koivisto
  2000-12-03 17:48 ` Bart Schaefer
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Hannu Koivisto @ 2000-12-03 14:01 UTC (permalink / raw)
  To: Zsh Users' List

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2000-12-07 17:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-03 14:01 Better ( rm foo; bar > foo ) < foo ? Hannu Koivisto
2000-12-03 17:48 ` Bart Schaefer
2000-12-03 23:17   ` Hannu Koivisto
2000-12-04  2:27     ` Bart Schaefer
2000-12-03 20:24 ` Clint Adams
2000-12-07 11:44 ` Danny Dulai
2000-12-07 14:17   ` Andrej Borsenkow
2000-12-07 17:10     ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).