summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-18 06:54:47 +0800
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2022-08-18 15:04:02 +0000
commita7f4d0a78275cd7ef9dea8b1adc2f531cef5e16d (patch)
tree5e8800582a6734945d0d2de51628ce5ed1e358a7
parent44205fe516990fc753fd7dc31f5929508c452cfd (diff)
revert: "jobstart(): Fix hang on non-executable cwd #9204"
This reverts commit c4c74c3883aa3122c0c877ca8dd7b26beb5cc4aa. LibUV already gives an error for this, so this isn't needed. (cherry picked from commit b94e2c8520d56b61dee7414f76a4fcdb9113d5d8)
-rw-r--r--src/nvim/channel.c2
-rw-r--r--src/nvim/eval/funcs.c4
-rw-r--r--src/nvim/os/fs.c19
-rw-r--r--test/functional/core/job_spec.lua5
4 files changed, 5 insertions, 25 deletions
diff --git a/src/nvim/channel.c b/src/nvim/channel.c
index ac6c9cd110..c57f06c353 100644
--- a/src/nvim/channel.c
+++ b/src/nvim/channel.c
@@ -316,8 +316,6 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout, CallbackReader
ChannelStdinMode stdin_mode, const char *cwd, uint16_t pty_width,
uint16_t pty_height, dict_T *env, varnumber_T *status_out)
{
- assert(cwd == NULL || os_isdir_executable(cwd));
-
Channel *chan = channel_alloc(kChannelStreamProc);
chan->on_data = on_stdout;
chan->on_stderr = on_stderr;
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index c9ba98dfbc..527fbd4f34 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -5221,7 +5221,7 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (new_cwd && *new_cwd != NUL) {
cwd = new_cwd;
// The new cwd must be a directory.
- if (!os_isdir_executable((const char *)cwd)) {
+ if (!os_isdir((const char_u *)cwd)) {
semsg(_(e_invarg2), "expected valid directory");
shell_free_argv(argv);
return;
@@ -10737,7 +10737,7 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr)
if (new_cwd && *new_cwd != NUL) {
cwd = new_cwd;
// The new cwd must be a directory.
- if (!os_isdir_executable(cwd)) {
+ if (!os_isdir((const char_u *)cwd)) {
semsg(_(e_invarg2), "expected valid directory");
shell_free_argv(argv);
return;
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index daf974ee74..38d3419926 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -146,25 +146,6 @@ bool os_isdir(const char_u *name)
return true;
}
-/// Check if the given path is a directory and is executable.
-/// Gives the same results as `os_isdir()` on Windows.
-///
-/// @return `true` if `name` is a directory and executable.
-bool os_isdir_executable(const char *name)
- FUNC_ATTR_NONNULL_ALL
-{
- int32_t mode = os_getperm(name);
- if (mode < 0) {
- return false;
- }
-
-#ifdef WIN32
- return (S_ISDIR(mode));
-#else
- return (S_ISDIR(mode) && (S_IXUSR & mode));
-#endif
-}
-
/// Check what `name` is:
/// @return NODE_NORMAL: file or directory (or doesn't exist)
/// NODE_WRITABLE: writable device, socket, fifo, etc.
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index 12bb4d24d3..b17a08bb87 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -21,6 +21,7 @@ local nvim_set = helpers.nvim_set
local expect_twostreams = helpers.expect_twostreams
local expect_msg_seq = helpers.expect_msg_seq
local pcall_err = helpers.pcall_err
+local matches = helpers.matches
local Screen = require('test.functional.ui.screen')
describe('jobs', function()
@@ -229,8 +230,8 @@ describe('jobs', function()
local dir = 'Xtest_not_executable_dir'
mkdir(dir)
funcs.setfperm(dir, 'rw-------')
- eq('Vim(call):E475: Invalid argument: expected valid directory',
- pcall_err(nvim, 'command', "call jobstart('pwd', {'cwd': '"..dir.."'})"))
+ matches('^Vim%(call%):E903: Process failed to start: permission denied: .*',
+ pcall_err(nvim, 'command', "call jobstart(['pwd'], {'cwd': '"..dir.."'})"))
rmdir(dir)
end)