Thread View: net.bugs
9 messages
9 total messages
Started by David Herron, NPR Lover
Wed, 21 Aug 1985 02:48
Vi isn't nasty enough, so user looses lines
Author: David Herron, NPR Lover
Date: Wed, 21 Aug 1985 02:48
Date: Wed, 21 Aug 1985 02:48
21 lines
1256 bytes
1256 bytes
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!
Re: Vi isn't nasty enough, so user looses lines
Author: Jeff Anton
Date: Fri, 23 Aug 1985 04:42
Date: Fri, 23 Aug 1985 04:42
23 lines
1496 bytes
1496 bytes
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
Re: Vi isn't nasty enough, so user looses lines
Author: Richard L. Klappal
Date: Fri, 23 Aug 1985 07:24
Date: Fri, 23 Aug 1985 07:24
33 lines
1861 bytes
1861 bytes
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) -------------------------------------------------------------------------
Re: Vi isn't nasty enough, so user looses lines
Author: Tanner Andrews
Date: Fri, 23 Aug 1985 13:21
Date: Fri, 23 Aug 1985 13:21
17 lines
1398 bytes
1398 bytes
] 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
Re: Vi isn't nasty enough, so user looses lines
Author: Daniel R. Levy
Date: Sat, 24 Aug 1985 05:39
Date: Sat, 24 Aug 1985 05:39
32 lines
2329 bytes
2329 bytes
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
Re: Re: Vi isn't nasty enough, so user looses lines
Author: Peter da Silva
Date: Thu, 29 Aug 1985 16:33
Date: Thu, 29 Aug 1985 16:33
10 lines
926 bytes
926 bytes
> 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
In vi, ZZ is not :wq
Author: Al Filipski
Date: Fri, 13 Sep 1985 20:53
Date: Fri, 13 Sep 1985 20:53
34 lines
1430 bytes
1430 bytes
*
In "Re: Re: Vi isn't nasty enough, so user looses lines", there is the
exchange:
>
> > ZZ is shorthand for :wq
> > :wq means write it out & quit
>
> ZZ is shorthand for :x<CR>
>
ZZ is NOT equivalent to either :wq or :x on our System V.2 vi,
but differs from the latter two (which seem to be equivalent) in
an insidious way. For example, for an existing file foo,
vi foo
<change some things>
:w bar
ZZ
does NOT cause the changes to be written to foo. However,
vi foo
<change some things>
:w bar
:wq
DOES. ZZ apparently tries to be smart and avoid unnecessary writes,
but I would expect it to write the file being edited in the case
above. A bug, I'd call it.
--------------------------------
Alan Filipski, UNIX group, Motorola Microsystems, Tempe, AZ U.S.A
{seismo|ihnp4}!ut-sally!oakhill!mot!al
ucbvax!arizona!asuvax!mot!al
--------------------------------
Re: In vi, ZZ is not :wq
Author: Robert Elz
Date: Sat, 14 Sep 1985 06:09
Date: Sat, 14 Sep 1985 06:09
34 lines
2166 bytes
2166 bytes
In article <269@mot.UUCP>, al@mot.UUCP (Al Filipski) writes: > ZZ is NOT equivalent to either :wq or :x on our System V.2 vi, > vi foo > <change some things> > :w bar > ZZ > > does NOT cause the changes to be written to foo. > > ZZ apparently tries to be smart and avoid unnecessary writes, > but I would expect it to write the file being edited in the case > above. A bug, I'd call it. Wrong. ZZ writes the file in exactly the same cases as ":q" would say "file modified and not written" and not exit. Its a shorthand for people who get tired of that message, but don't want to get into the habbit of ":wq" (or ":x") every time they want to exit (which write the file every time, changed or not). The relevant point is that ZZ will not write the file if the changes exist somewhere - they may not be in the original file that you edited if you saved them elsewhere (but when I do this, I usually (99% of cases) DON'T want the changes written back to the original file) - but they do exist somewhere (maybe /dev/null if you did a ":w /dev/null" which is a useful technique at times). This discussion started when someone reported that after a "vi -r" an immediate ZZ would lose the file (not write it). That was a bug, and is fixed in 4.3 (simply a matter of the "changed" flag not being set after a "recover" operation), ":q" would have silently exited in the same circumstances. Robert Elz seismo!munnari!kre kre%munnari.oz@seismo.css.gov
Re: In vi, ZZ is not :wq
Author: Chris Torek
Date: Sat, 14 Sep 1985 20:20
Date: Sat, 14 Sep 1985 20:20
17 lines
1433 bytes
1433 bytes
In article <914@munnari.OZ> kre@munnari.OZ (Robert Elz) writes: >ZZ ... [is] a shorthand for people who ... don't want to get into >the habbit of ":wq" (or ":x") every time they want to exit (which >write the file every time, changed or not). Aha! The great kre finally makes a mistake! I've been waiting for this for a long time . . . :-) ``ZZ'' is exactly equivalent to ``:x'' (in fact it puts an ``x'' command into glob and goes to doinit, which amounts to pretending the user typed ``:x''). Seriously, though, the rest of what he said is correct; ``ZZ'' is not intended to be equivalent to ``:wq''. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads