two unix questions -- propriety of vi -r

Ray Lubinsky rwl at uvacs.UUCP
Wed Oct 29 01:09:49 AEST 1986


> 2) Why does 'vi -r file' not set the 'dirty bit' (or whatever it's called)
>    so that an immediate exit with ZZ will save the file. I lost some 
>    changes after a crash because I had to leave and in my haste just
>    entered vi (ala above) and exited with ZZ. This did not save my file.
>    I think it should have. Any thoughts?
> 

I had a professor here ask me the same question, hoping that I would ``fix''
vi(1) so that it would automatically write a recovered file with ``ZZ'' (even
though ``vi -r'' is documented as behaving as it does).  Just as I was diddling
with a copy of one of the source files, the system crashed.  When we came back
up, I got mail saying that the edit buffer had been saved, even though I had
just written the file a few minutes before the crash.

Rather than just overwrite what I had, I did a diff on my most recent version
and the version saved by vi(1)...  Sure enough, *my* version was more up-to-
date than the saved buffer.  Perhaps you'll see as I did that you don't want an
automatic write on recovery; if it had automatically ``updated'' my file, I
would have been robbed of my most recent version.

Why does ``vi -r'' do what it does?  Because you *need* to evaluate whether the
saving of the edit buffer was successful or not.  I guess that the problem comes
in making the recovery of a saved buffer look just like a regular edit session
when, in fact, it shouldn't be.

-- 

| Ray Lubinsky         Department of Computer Science, University of Virginia |
|                      INTERNET:  rwl at uvacs.cs.virginia.edu                   |
|                      CSNET:     rwl%virginia at csnet-relay                    |
|                      UUCP:      ...!cbosgd!uvacs!rwl                        |



More information about the Comp.unix.wizards mailing list