代码:
(progn
(start-process "my-process" "my-process-output" "bash")
(process-send-string "my-process" "ls -al ~"))
运行时,我只得到
bash-3.2$
“my-process”是否在“process-send-string”之前终止?我的目标并不是特别向“bash”进程发出命令。它实际上更通用 - 即使用 process-send-string 将命令提供给现有的子进程。我尝试将 nil 参数传递给 start-process,希望 emacs 在传递给任何具体参数之前以某种方式为我启动一个进程占位符,但这也没有帮助。
(progn
(start-process "my-process" "my-process-output" nil)
(process-send-string "my-process" "bash -c \"ls -al ~\""))
这样做的方法是什么?
最佳答案
在输入 ls
命令后尝试使用换行符(按 Enter 键):
(process-send-string "my-process" "ls -al ~\n"))
关于emacs - Elisp 如何在退出之前向子进程提供带有 process-send-string 的命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19193235/