Prompt for input in using the grunt-shell plugin

我只是一个虾纸丫 提交于 2019-12-12 14:08:59

问题


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".

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?

So, my question is, is there any way to prompt for user input from the grunt-shell plugin?

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.


回答1:


I redirected my code back to /dev/tty. Ran it as bash -c run.sh </dev/tty



来源:https://stackoverflow.com/questions/27807982/prompt-for-input-in-using-the-grunt-shell-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!