Fwd: Re: [BUG] vi does not recognize changed permissions on read only files

Doug Clapp doug.clapp at triad.rr.com
Thu Oct 11 01:37:50 UTC 2012



-------- Original Message --------
Subject: 	Re: [BUG] vi does not recognize changed permissions on read 
only files
Date: 	Wed, 10 Oct 2012 20:50:07 -0400
From: 	Doug Clapp <doug.clapp at triad.rr.com>
Reply-To: 	doug.clapp1970 at alumni.unc.edu
To: 	Manuel Zerpies <manuel.f.zerpies at ww.stud.uni-erlangen.de>



Manuel Zerpies wrote:
> hej john,
>
>> i edited less-444/configure, and when i wanted to :wq vi claimed:
>> "file is read-only".
>>
>> so i changed the perms in another shell to 755.
>> retrying :wq yielded the same error again.
>>
>> after closing vi with :q! and opening it again, i was able to save it.
>>
>> i had to redo all previous changes of course...
> yes. but that is kind of "normal" behavior.
>
> try the following:
>
> $ touch test.txt
> $ chmod 444 test.txt
>
> now the file is readonly and you got the situation as mentioned.
> it is not relevant whether you use vim or vi
>
> $ vi test.txt
>
> edit the text file and try to close with ":wq". won't work - as
> intended.
>
> (other shell)
> chmod 755 test.txt
>
> back to vi(m) ":wq" won't work, because you opened the file
> readonly. so where is the bug?
>
> you don't open the file, but the filedescriptor. the file is not
> harmed yet. so what you get is a readonly filedescriptor.
>
> does your example work with the version of vi shipped by your
> distribution in your /bin or /usr/bin folder?
>
> greets,
> manuel
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
>
I tried the equivalent with 3 editors. My distribution ships with "vi"
aliased to "e3vi" which is a link to "e3". I also have vim 7.2 and
Busybox v1.20.0.git. My results were:

e3vi made the change and rewrote the file, even with 444 permissions.

vim warned the file was read only and did not complete the write but did
advise me to repeat with "!" and indeed "w!" did rewrite the file

busybox vi did not write the file, told me it was read only, but did not
offer the advice about "!"; however, when I subsequently used "w!" it
did write the file

another way to keep your changes with vim (and I think the original vi)
is to write to another file, for example ":wtest2.txt" then quit but
that does not appear to work with busybox vi. However, "w! newfile" does
appear to work (and I think the space is necessary)

Doug Clapp

retransmission to list - apparently the first time I sent he above only to manuel

Doug Clapp



More information about the busybox mailing list