Replying to myself to add the missing [PATCH] header in the subject line, and give an easier-to-parse version of this patch. Sorry, I was a bit sleepy yesterday.

This basically fixes a bug where after you open a read only file, you can't write it anywhere any more. The error message was also misleading, since if you did :w other-name, it would tell you that other-name was read only when it wasn't.

Anyway, take two.

---
 editors/vi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/editors/vi.c b/editors/vi.c
index abc0aeae8..9d603b6f2 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -2822,13 +2822,12 @@ static void colon(char *buf)
                // is there a file name to write to?
                if (args[0]) {
                        fn = args;
-               }
 # if ENABLE_FEATURE_VI_READONLY
-               if (readonly_mode && !useforce) {
+               } else if (readonly_mode && !useforce) {
                        status_line_bold("'%s' is read only", fn);
                        goto ret;
-               }
 # endif
+               }
                //if (useforce) {
                        // if "fn" is not write-able, chmod u+w
                        // sprintf(syscmd, "chmod u+w %s", fn);
--
2.30.1



On Tue, 2 Mar 2021, Alison Winters wrote:

---
editors/vi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/editors/vi.c b/editors/vi.c
index abc0aeae8..8bb126d14 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -2824,7 +2824,7 @@ static void colon(char *buf)
                        fn = args;
                }
# if ENABLE_FEATURE_VI_READONLY
-               if (readonly_mode && !useforce) {
+               else if (readonly_mode && !useforce) {
                        status_line_bold("'%s' is read only", fn);
                        goto ret;
                }
--
2.30.1


_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to