[net.bugs] Vi isn't nasty enough, so user looses lines

david@ukma.UUCP (David Herron, NPR Lover) (08/21/85)

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.

		:-)
-- 
--- David Herron
--- ARPA-> ukma!david@ANL-MCS.ARPA
--- UUCP-> {ucbvax,unmvax,boulder,oddjob}!anlams!ukma!david
---        {ihnp4,decvax,ucbvax}!cbosgd!ukma!david

Hackin's in me blood.  My mother was known as Miss Hacker before she married!

anton@ucbvax.ARPA (Jeff Anton) (08/23/85)

In article <2073@ukma.UUCP> david@ukma.UUCP (David Herron, NPR Lover) writes:
>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.

And you did not expect this?  The command ':wq' means WRITE and quit.
The command 'ZZ' or ':x' means write if the file has been changed
and not written anywhere and then exit.  Vi is nasty enough thank you.

Glad to help a confused professionnal.  At least he loves NPR.
-- 
C knows no bounds.
					Jeff Anton
					U.C.Berkeley
					ucbvax!anton
					anton@berkeley.ARPA

rlk@chinet.UUCP (Richard L. Klappal) (08/23/85)

In article <2073@ukma.UUCP> david@ukma.UUCP (David Herron, NPR Lover) writes:
>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.
>
>
>Hackin's in me blood.  My mother was known as Miss Hacker before she married!

Not sure I understand the problem!!
ZZ is shorthand for :wq
:wq means write it out & quit
if you don't want to modify the original (and didn't set readonly 
[ -R option ], the correct way to exit is :q! which is quit & discard
changes.

In your example it did EXACTLY what you told it to.



Richard Klappal

UUCP:		..!ihnp4!chinet!uklpl!rlk  | "Money is truthful.  If a man
MCIMail:	rklappal		   | speaks of his honor, make him
Compuserve:	74106,1021		   | pay cash."
USPS:		1 S 299 Danby Street	   | 
		Villa Park IL 60181	   |	Lazarus Long 
TEL:		(312) 620-4988		   |	    (aka R. Heinlein)
-------------------------------------------------------------------------

tanner@ki4pv.UUCP (Tanner Andrews) (08/23/85)

] description of user deleting lines, saving part of file, doing
] normal exit (":wq") from vi to save whole file, not getting warning.

It sounds like a normal job of work being done on a file.  Perhaps
part of a program being ripped out, as it the code it was there to
debug turned out not to contain the problem; the total job being
finished in the normal manner.

What kind of warning should the user get?  Is this warning to be
applied to all work done in the editor?  Maybe I need to eat more
of those fine powdermilk biscuits, but do we need a warning like
(reverse-video on the line below -- add flashing and bells too)
"You are about to save your changes -- use wq! to really do it"?

-- 
<std dsclm, copies upon request>	   Tanner Andrews, KI4PV
uucp:					...!decvax!ucf-cs!ki4pv!tanner

levy@ttrdc.UUCP (Daniel R. Levy) (08/24/85)

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

peter@baylor.UUCP (Peter da Silva) (08/29/85)

> ZZ is shorthand for :wq
> :wq means write it out & quit

ZZ is shorthand for :x<CR>

You mean you actually thought the original poster was serious?
-- 
	Peter (Made in Australia) da Silva
		UUCP: ...!shell!neuro1!{hyd-ptd,baylor,datafac}!peter
		MCI: PDASILVA; CIS: 70216,1076