if (!(supported2 & JO2_CWD))
break;
opt->jo_cwd = get_tv_string_buf_chk(item, opt->jo_cwd_buf);
- if (opt->jo_cwd == NULL || !mch_isdir(opt->jo_cwd))
+ if (opt->jo_cwd == NULL || !mch_isdir(opt->jo_cwd)
+ || mch_access((char *)opt->jo_cwd, X_OK) != 0)
{
EMSG2(_(e_invargval), "cwd");
return FAIL;
call delete('Xdir', 'rf')
endfunc
+func Test_terminal_cwd_failure()
+ " Case 1: Provided directory is not actually a directory. Attempt to make
+ " the file executable as well.
+ call writefile([], 'Xfile')
+ call setfperm('Xfile', 'rwx------')
+ call assert_fails("call term_start(&shell, {'cwd': 'Xfile'})", 'E475:')
+ call delete('Xfile')
+
+ " Case 2: Directory does not exist.
+ call assert_fails("call term_start(&shell, {'cwd': 'Xdir'})", 'E475:')
+
+ " Case 3: Directory exists but is not accessible.
+ call mkdir('Xdir', '', '0600')
+ " return early if the directory permissions could not be set properly
+ if getfperm('Xdir')[2] == 'x'
+ call delete('Xdir', 'rf')
+ return
+ endif
+ call assert_fails("call term_start(&shell, {'cwd': 'Xdir'})", 'E475:')
+ call delete('Xdir', 'rf')
+endfunc
+
func Test_terminal_servername()
if !has('clientserver')
return