mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
Merge pull request #19833 from neovim/backport-19826-to-release-0.7
[Backport release-0.7] revert: "jobstart(): Fix hang on non-executable cwd #9204"
This commit is contained in:
commit
6ec04e590f
@ -316,8 +316,6 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout, CallbackReader
|
|||||||
ChannelStdinMode stdin_mode, const char *cwd, uint16_t pty_width,
|
ChannelStdinMode stdin_mode, const char *cwd, uint16_t pty_width,
|
||||||
uint16_t pty_height, dict_T *env, varnumber_T *status_out)
|
uint16_t pty_height, dict_T *env, varnumber_T *status_out)
|
||||||
{
|
{
|
||||||
assert(cwd == NULL || os_isdir_executable(cwd));
|
|
||||||
|
|
||||||
Channel *chan = channel_alloc(kChannelStreamProc);
|
Channel *chan = channel_alloc(kChannelStreamProc);
|
||||||
chan->on_data = on_stdout;
|
chan->on_data = on_stdout;
|
||||||
chan->on_stderr = on_stderr;
|
chan->on_stderr = on_stderr;
|
||||||
|
@ -5221,7 +5221,7 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
if (new_cwd && *new_cwd != NUL) {
|
if (new_cwd && *new_cwd != NUL) {
|
||||||
cwd = new_cwd;
|
cwd = new_cwd;
|
||||||
// The new cwd must be a directory.
|
// 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");
|
semsg(_(e_invarg2), "expected valid directory");
|
||||||
shell_free_argv(argv);
|
shell_free_argv(argv);
|
||||||
return;
|
return;
|
||||||
@ -10737,7 +10737,7 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
if (new_cwd && *new_cwd != NUL) {
|
if (new_cwd && *new_cwd != NUL) {
|
||||||
cwd = new_cwd;
|
cwd = new_cwd;
|
||||||
// The new cwd must be a directory.
|
// 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");
|
semsg(_(e_invarg2), "expected valid directory");
|
||||||
shell_free_argv(argv);
|
shell_free_argv(argv);
|
||||||
return;
|
return;
|
||||||
|
@ -146,25 +146,6 @@ bool os_isdir(const char_u *name)
|
|||||||
return true;
|
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:
|
/// Check what `name` is:
|
||||||
/// @return NODE_NORMAL: file or directory (or doesn't exist)
|
/// @return NODE_NORMAL: file or directory (or doesn't exist)
|
||||||
/// NODE_WRITABLE: writable device, socket, fifo, etc.
|
/// NODE_WRITABLE: writable device, socket, fifo, etc.
|
||||||
|
@ -21,6 +21,7 @@ local nvim_set = helpers.nvim_set
|
|||||||
local expect_twostreams = helpers.expect_twostreams
|
local expect_twostreams = helpers.expect_twostreams
|
||||||
local expect_msg_seq = helpers.expect_msg_seq
|
local expect_msg_seq = helpers.expect_msg_seq
|
||||||
local pcall_err = helpers.pcall_err
|
local pcall_err = helpers.pcall_err
|
||||||
|
local matches = helpers.matches
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
|
|
||||||
describe('jobs', function()
|
describe('jobs', function()
|
||||||
@ -229,8 +230,8 @@ describe('jobs', function()
|
|||||||
local dir = 'Xtest_not_executable_dir'
|
local dir = 'Xtest_not_executable_dir'
|
||||||
mkdir(dir)
|
mkdir(dir)
|
||||||
funcs.setfperm(dir, 'rw-------')
|
funcs.setfperm(dir, 'rw-------')
|
||||||
eq('Vim(call):E475: Invalid argument: expected valid directory',
|
matches('^Vim%(call%):E903: Process failed to start: permission denied: .*',
|
||||||
pcall_err(nvim, 'command', "call jobstart('pwd', {'cwd': '"..dir.."'})"))
|
pcall_err(nvim, 'command', "call jobstart(['pwd'], {'cwd': '"..dir.."'})"))
|
||||||
rmdir(dir)
|
rmdir(dir)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user