提示输入使用grunt-shell插件 [英] Prompt for input in using the grunt-shell plugin
问题描述
我有一个脚本,正在尝试使用grunt-shell插件与grunt一起运行.该脚本使用read -p "enter foo" bar
提示输入.当我运行它时,我得到一个光标,该光标正确地接受了我的输入,但是看不到"enter foo".
I have a script I am trying to run with grunt using the grunt-shell plugin. This script prompts for input using read -p "enter foo" bar
. When I run it, I get a cursor that correctly takes my input, but I don't see "enter foo".
我尝试修改grunt-shell配置以将err,stderr和stdout转储到控制台,但是一旦命令完成,它们都将变为空. read的手册页中提到-p标志仅当输入来自终端时才显示提示."这似乎是我的问题,因为节点正在调用提示,但是read命令正在我的命令行中执行终端,而我正在终端中输入输入,那为什么不起作用?
I tried modifying the grunt-shell config to dump err, stderr, and stdout to the console, but they all come out empty once the command completes. The man page for read says about the -p flag "The prompt is displayed only if input is coming from a terminal.", which seems like it may be my issue since node is calling the prompt, but the read command is executing in my terminal, and I am entering input in a terminal, so why wouldn't that work?
所以,我的问题是,有什么方法可以提示用户从grunt-shell插件输入吗?
So, my question is, is there any way to prompt for user input from the grunt-shell plugin?
此外,作为一个PS,是的,我知道仅回显提示并处理其下方的输入将非常容易,但是该死的是原理.
Also, as a P.S., yes i know it would be very easy to just echo the prompt and deal with the input being below it, but dammit it's the principle of the thing.
推荐答案
我将代码重定向回/dev/tty.
以bash -c run.sh </dev/tty
I redirected my code back to /dev/tty.
Ran it as bash -c run.sh </dev/tty
这篇关于提示输入使用grunt-shell插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!