> I've searched the archives for this one; I suppose
> it's too simple a question to be found there: how
> does one edit (and then write or "Put") another
> owner's files in Acme? e.g., I have root access,
> but don't want to run my whole acme session
> as root just so that I can make quick edits to
> /etc/hosts, or another user's .exrc or something.
>  I'll use 'sudo ed' inside "win", but sometimes
> I'd rather not.  Is there something like a "SudoPut"?

Acme is blissfully ignorant of such things.
I typically chmod the files so that I'm allowed to
write them directly.  However, it's easy to implement
what you want.  Here is a shell script called Put! that
uses sudo to write the current buffer out.  (Note that
to execute Put! you have to highlight the whole string,
since the autoexpand won't use the !.)

---
#!/usr/local/plan9/bin/rc

# Execute Put! instead of Put to force write via sudo.

. 9.rc
dir=acme/acme/$winid
fn rd {
        9p read $dir/$1 || { echo 9p failed >[1=2]; exit 9p }
}
fn wr {
        9p write $dir/$1 || { echo 9p failed >[1=2]; exit 9p }
}

switch($#*){
case 0
        tag=`{rd tag}
        file=$tag(1)
        if(~ $file '$'*){
                file=`{eval echo $file}
                file=$"file
        }
case *
        file=$1
}

tmp=/tmp/put!.$pid
echo -n , | wr addr
rd data >$tmp
if(sudo cp $tmp $file)
        echo -n clean | wr ctl
rm -f $tmp
---

Russ

Reply via email to