[linux-elitists] WindowManagers

Mark van Walraven mvw@wave.co.nz
Thu Jan 15 19:05:58 PST 2004


On Tue, Jan 13, 2004 at 10:24:47PM -0800, Jason Spence wrote:
> #!/bin/sh
> # manlyedit -- because emacs and vi users are pussies.
> 
> usage() {
>     echo "Usage: echo NEWLINE | manlyedit FILE LINENUM # you stupid twit"
> }
> 
> if test $# -lt 2; then
>     usage
>     exit 1
> fi
> 
> read input
> 
> sed -e "$2s/.*/$input/" < $1 > $1.new
> mv $1.new $1

Hmmm, how about replacing the last two lines with:

        { rm $1 ; sed -e "$2s/.*/$input/" > $1 ; } < $1

That guarantees losing the original file if you interrupt the script
while sed is still running[1] and won't ever leave a temporary file
lying around to offend someone. 

[1] If you weren't sure, you shouldn't have hit enter.

Mark.



More information about the linux-elitists mailing list