Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Better ( rm foo; bar > foo ) < foo ?



How about

	mv -i =(bar < foo) foo

??  As long as `bar' produces some kind of failure output, that should be OK
for interactive use.

A little more input on what you think would NOT be clumsy would help.  For
example, would

	rewrite sed 's/foo/bar/g' foo

be OK?  Just take your original "in a script, I'd probably write" and put
it in a function:

    rewrite() {
	local TMPFILE=${TMPPREFIX}rewrite.$$	# Whatever
	$argv[1,-2] < $argv[-1] > $TMPFILE || rm -f $TMPFILE
	[[ -f $TMPFILE ]] && mv -f $TMPFILE $argv[-1]
    }

You can probably figure out what to do if you'd prefer the syntax

	rewrite foo sed 's/foo/bar/g'

instead ...

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



Messages sorted by: Reverse Date, Date, Thread, Author