forked from aniani/vim
patch 8.2.2856: get readonly error for device that can't be written to
Problem: Get readonly error for device that can't be written to. Solution: Check for being able to write first. (closes #8205)
This commit is contained in:
@@ -1856,6 +1856,19 @@ ex_write(exarg_T *eap)
|
|||||||
(void)do_write(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'
|
* write current buffer to file 'eap->arg'
|
||||||
* if 'eap->append' is TRUE, append to the file
|
* if 'eap->append' is TRUE, append to the file
|
||||||
@@ -1942,7 +1955,11 @@ do_write(exarg_T *eap)
|
|||||||
#ifdef FEAT_QUICKFIX
|
#ifdef FEAT_QUICKFIX
|
||||||
bt_dontwrite_msg(curbuf) ||
|
bt_dontwrite_msg(curbuf) ||
|
||||||
#endif
|
#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;
|
goto theend;
|
||||||
|
|
||||||
if (!other)
|
if (!other)
|
||||||
|
@@ -285,7 +285,7 @@ func Test_write_errors()
|
|||||||
\ && getftype('/dev/loop0') == 'bdev' && !IsRoot()
|
\ && getftype('/dev/loop0') == 'bdev' && !IsRoot()
|
||||||
new
|
new
|
||||||
edit /dev/loop0
|
edit /dev/loop0
|
||||||
call assert_fails('write', 'E505: ')
|
call assert_fails('write', 'E503: ')
|
||||||
call assert_fails('write!', 'E503: ')
|
call assert_fails('write!', 'E503: ')
|
||||||
close!
|
close!
|
||||||
endif
|
endif
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2856,
|
||||||
/**/
|
/**/
|
||||||
2855,
|
2855,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user