Bug in vi-applet: ZZ command does not recognize read-only files
Paul Fox
pgf at brightstareng.com
Mon Mar 27 05:36:43 PST 2006
>
> When I open a file in vi and modify it in the buffer (although it's
> readonly) and afterwards try to save it using the ":wq" command, I get
> the error message that the file is read-only. If I do ":wq!", I get
> another error message from the write command itself that the file can't
> be written, so far so good.
>
> When I do the same with the "ZZ" command (which should be an equivalent
> to :wq or :x) I don't get an error message that the file is not
> writable, vi simply quits and returns 0 to the shell and makes me think
> that everything is ok.
i'll take a look at this. when i fixed the read-only behavior of
:wq last year, i didn't notice that ZZ had the same problem.
i'll look at your ":wn" as well.
paul
>
> It took me quite a while to find out what was wrong because I thought
> I definetly made some modifications to a file and after reboot the same
> errors that should have been gone using the modifications still were
> there.
>
> So, in short, here's a patch that fixes the ZZ command to not quit when
> the file is read-only but instead show an error message that the file
> is read-only and continue editing.
>
> As my last patch to :wn didn't apply to the current release, I'm asking
> you what did I wrong?
>
> This patch is against busybox 1.1.1 which I downloaded about three days
> ago, so I hope it applies.
>
> ciao,
> - --
> Alexander Griesser (Netzwerkadministration)
> E-Mail: alexander.griesser at lkh-vil.or.at | Web: http://www.lkh-vil.or.at
> KABEG LKH Villach | Nikolaigasse 43 | 9500 Villach
> Tel.: +43 4242 208 3061 | Fax.: +43 4242 971 3061
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2.2 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFEJ+H+66HVD6KUm1oRAjxnAJ0fH3opPQxw8wCO1NyoIHKkY4hpjwCfaDV4
> Yfm3bF/6rWMzeOWGtOsHtJ0=
> =7/i3
> -----END PGP SIGNATURE-----
>
> --------------030901070702040006010307
> Content-Type: text/x-patch;
> name="vi-ro-ZZ-issue.diff"
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline;
> filename="vi-ro-ZZ-issue.diff"
>
> --- vi.c.orig 2006-03-27 14:59:36.400002282 +0200
> +++ vi.c 2006-03-27 15:00:03.017543741 +0200
> @@ -3640,7 +3640,8 @@
> editing = 0;
> }
> } else {
> - editing = 0;
> + psbs("\"%s\" File is read only", cfn);
> + goto dc1;
> }
> break;
> case '^': // ^- move to first non-blank on line
>
> --------------030901070702040006010307
> Content-Type: text/plain; charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox
> --------------030901070702040006010307--
=---------------------
paul fox, pgf at brightstareng.com
More information about the busybox
mailing list