以编程方式将数据发送到 bash stdin

问题描述 投票:0回答:1

我想以编程方式更改 shell 中的用户输入,类似于内置的

complete
shell 实现此目的的方式。

因此,每当您按 TAB 时,unix 系统都会内置完整的附加一些数据到您的输入。我想达到与已经运行的 shell 类似的效果。

我尝试的大多数方法只是在终端中显示字符,但无法将它们解释为命令。

echo "New input" > /proc/<bashID>/fd/0
- 不起作用,仅在终端中写入“新输入”,无法将其编辑或解释为命令。

linux bash shell process stdio
1个回答
0
投票

我建议用

bash
:

read -i 'New input' -e variable

参见:

help read

© www.soinside.com 2019 - 2024. All rights reserved.