In message <http://marc.info/?l=openbsd-tech&m=144725499606130&w=1>,
Gregor Best <gbe () unobtanium ! de> wrote (about 'vi -R')
> I'd like to make this switch a permanent "never ever write a file that's
> not in /tmp or /var/tmp"-mode.

<disclaimer>
No patch attached. :(
</disclaimer>

A couple of comments:

Why is it ok to write to /var/tmp/foo, but not /usr/tmp/foo,
/home/tmp/foo, or /my/wierd/filesystem/layout/tmp/foo ?

Having 'vi -R' forbidden to write most files would remove a lot of
its utility for me:  I often use 'view' (= 'vi -R') to browse code
I'm working on when I'm not planning to make any changes (it prevents
me from accidentally changing the code with a finger-fumble).  But
after looking at the code, I sometimes then change my mind and decide
there's a change I want to make after all.  The present behavior allows
this cleanly (':w!'), but the new semantics would force a much more
cumbersome workflow (':w /tmp/foo'; then (in another window)
mv /tmp/foo /long/path/to/this/file/that/Id/rather/not/retype;
then '1GdG:r' to update the vi buffer; then manually navigate back
to wherever I was in the file).

But I can also see that having a true guarantee of "will *never* write
files (apart from a few specified escape-hatch places)" would be useful.
What about splitting -R into two switches:
* advisory read-only (behavior of the current 'vi -R')
* mandatory read-only (pledge(2) semantics Gregor proposed)

-- 
-- "Jonathan Thornburg [remove -animal to reply]" 
<[email protected]>
   Dept of Astronomy & IUCSS, Indiana University, Bloomington, Indiana, USA
   "There was of course no way of knowing whether you were being watched
    at any given moment.  How often, or on what system, the Thought Police
    plugged in on any individual wire was guesswork.  It was even conceivable
    that they watched everybody all the time."  -- George Orwell, "1984"

Reply via email to