Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site ttrdc.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!ihnp4!mgnetp!ltuxa!ttrdc!levy
From: levy@ttrdc.UUCP (Daniel R. Levy)
Newsgroups: net.bugs
Subject: Re: Vi isn't nasty enough, so user looses lines
Message-ID: <380@ttrdc.UUCP>
Date: Sat, 24-Aug-85 01:39:54 EDT
Article-I.D.: ttrdc.380
Posted: Sat Aug 24 01:39:54 1985
Date-Received: Sun, 25-Aug-85 03:16:22 EDT
References: <2073@ukma.UUCP>
Organization: AT&T, Computer Systems Division, Skokie, IL
Lines: 32

In article <2073@ukma.UUCP>, david@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