aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-04-25 11:52:55 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2021-04-28 11:29:33 +0200
commit09172582daa98f575a711de2f0e3cf3bf88b8346 (patch)
treeac5fe32ad6737d8fb7ce78705fe547cc7f9ccb5b
parent3b9233f05fc82029529f74fdce0e453d7fb73997 (diff)
downloadbusybox-w32-09172582daa98f575a711de2f0e3cf3bf88b8346.tar.gz
busybox-w32-09172582daa98f575a711de2f0e3cf3bf88b8346.tar.bz2
busybox-w32-09172582daa98f575a711de2f0e3cf3bf88b8346.zip
vi: saving unnamed file in readonly mode
Suppose vi is started with the command 'vi -R', that is, in readonly mode with no filename. Attempting to save the file with 'ZZ' or ':w' results in the message: '(null)' is read only Skip the code which prints this if no filename was provided, thus falling through to file_write() which gives the more helpful message 'No current filename'. function old new delta colon 3867 3874 +7 do_cmd 4668 4673 +5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 12/0) Total: 12 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/vi.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/editors/vi.c b/editors/vi.c
index d818127e2..a38f2189d 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -3054,7 +3054,7 @@ static void colon(char *buf)
3054 fn = args; 3054 fn = args;
3055 } 3055 }
3056# if ENABLE_FEATURE_VI_READONLY 3056# if ENABLE_FEATURE_VI_READONLY
3057 else if (readonly_mode && !useforce) { 3057 else if (readonly_mode && !useforce && fn) {
3058 status_line_bold("'%s' is read only", fn); 3058 status_line_bold("'%s' is read only", fn);
3059 goto ret; 3059 goto ret;
3060 } 3060 }
@@ -3996,7 +3996,7 @@ static void do_cmd(int c)
3996 break; 3996 break;
3997 } 3997 }
3998 if (modified_count) { 3998 if (modified_count) {
3999 if (ENABLE_FEATURE_VI_READONLY && readonly_mode) { 3999 if (ENABLE_FEATURE_VI_READONLY && readonly_mode && current_filename) {
4000 status_line_bold("'%s' is read only", current_filename); 4000 status_line_bold("'%s' is read only", current_filename);
4001 break; 4001 break;
4002 } 4002 }