summaryrefslogtreecommitdiffstats
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-05-15 23:21:05 +0200
committerBram Moolenaar <Bram@vim.org>2021-05-15 23:21:05 +0200
commit50157ef1c2e36d8696e79fd688bdd08312196bc6 (patch)
treea109334af9ba94e328cde5acc060622a12888834 /src/ex_cmds.c
parent0820f4de5872bfbdc25bf6cba6ec5646dbcec156 (diff)
patch 8.2.2856: get readonly error for device that can't be written tov8.2.2856
Problem: Get readonly error for device that can't be written to. Solution: Check for being able to write first. (closes #8205)
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r--src/ex_cmds.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 06109d57fb..e1497a5a4a 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -1856,6 +1856,19 @@ ex_write(exarg_T *eap)
(void)do_write(eap);
}
+#ifdef UNIX
+ static int
+check_writable(char_u *fname)
+{
+ if (mch_nodetype(fname) == NODE_OTHER)
+ {
+ semsg(_("E503: \"%s\" is not a file or writable device"), fname);
+ return FAIL;
+ }
+ return OK;
+}
+#endif
+
/*
* write current buffer to file 'eap->arg'
* if 'eap->append' is TRUE, append to the file
@@ -1942,7 +1955,11 @@ do_write(exarg_T *eap)
#ifdef FEAT_QUICKFIX
bt_dontwrite_msg(curbuf) ||
#endif
- check_fname() == FAIL || check_readonly(&eap->forceit, curbuf)))
+ check_fname() == FAIL
+#ifdef UNIX
+ || check_writable(curbuf->b_ffname) == FAIL
+#endif
+ || check_readonly(&eap->forceit, curbuf)))
goto theend;
if (!other)