Vi isn't nasty enough, so user looses lines

Daniel R. Levy levy at ttrdc.UUCP
Sat Aug 24 15:39:54 AEST 1985


In article <2073 at ukma.UUCP>, david at ukma.UUCP (David Herron, NPR Lover) writes:

>Index: Everybody's favorite text editor.
>
>Problem: Vi allows users to :wq without comment when they've
>	deleted part of the file and written it to something else.
>	This can result in lost files and confused novices.
>
>Repeat-by: Edit a file.  Delete part of the file.  (dG)  Write
>	the result to another file (:w junk).  Exit by either
>	typing :wq or ZZ.  Notice that the original is shorter.
>	Find backup tape.
>
>Fix:  Add more nastiness to vi.
>
What system (USG or Berkeley)?  What version vi?  I just tried this on a
3B20 running Sys5r2 and after deleting a few lines from a copy of my mbox
I did a :w junk, then a ZZ.  A diff between the copy and my mbox showed they
were the same.  Trying this with :w junk, then :wq did indeed overwrite the
original.  Looks like you get just what you ask for when you :wq but ZZ
seems to protect your hide OK.  The buffer modified condition is cleared
whenever you write the whole thing to a file--could be /dev/null for all vi
cares.  ZZ honors this condition (and won't overwrite the original), :wq does
NOT!!  (Someone else with a different version may feel free to contradict me.)
-- 
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer, my pets, my plants, my boss, or the
| at&t computer systems division |  s.a. of any computer upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!ihnp4!ttrdc!levy
                                      or: ..!ihnp4!iheds!ttbcad!levy



More information about the Net.bugs mailing list