-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Open
Labels
job-controlOS processes, spawnOS processes, spawn
Description
Problem
hi, i'm trying to port echo hello | sudo dd of=outfile
to lua, the following code is what i got so far, and it works not.
the problem is the data sent by chansend()
also goes to tty which should be stdin as it claimed in its doc.
Steps to reproduce
- nvim --clean +'luafile test.lua'
- (test.lua wants to behave like shell
echo hello | sudo dd of=/tmp/outfile
) - in the opened terminal, you can see 'hello' be showed in there, and it is a part of the password which is received by
sudo
, sosudo
will ask you to enter password again.
the test.lua:
local uv = vim.loop
local api = vim.api
local bufnr = api.nvim_create_buf(false, true)
-- stylua: ignore
api.nvim_open_win(bufnr, true, {
relative = "editor", style = "minimal", col = 0, row = 0, width = vim.o.columns, height = vim.o.lines,
})
local term = vim.fn.termopen({ "sudo", "dd", "of=/tmp/outfile" }, {
stdin = "pipe",
pty = true,
})
vim.cmd.startinsert()
vim.fn.chansend(term, "hello")
Expected behavior
as i'm carefully using jobstart(pty = true, stdin = 'pipe')
, i do think the test.lua should work with no problem, stdin and pty should be different things, thus chansend(job, data)
should just send data to stdin rather than pty.
Neovim version (nvim -v)
NVIM v0.8.3
Vim (not Nvim) behaves the same?
N/A
Operating system/version
archlinux
Terminal name/version
st 0.8.5
$TERM environment variable
tmux-256color
Installation
system package manager
Metadata
Metadata
Assignees
Labels
job-controlOS processes, spawnOS processes, spawn