从卷曲管运行bash的时候读被跳过 [英] bash read is being skipped when run from curl pipe

查看:152
本文介绍了从卷曲管运行bash的时候读被跳过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建一个github上项目的引导,并希望这是一个简单的一行。该脚本需要输入密码。

I'm building a bootstrap for a github project and would like it to be a simple one-liner. The script requires a password input.

这工作和停止脚本等待输入:

This works and stops the script to wait for an input:

curl -s https://raw.github.com/willfarrell/.vhosts/master/setup.sh -o setup.sh
bash setup.sh

这不,刚跳过输入请求:

This does not, and just skips over the input request:

curl -s https://raw.github.com/willfarrell/.vhosts/master/setup.sh | bash

setup.sh包含code是这样的:

setup.sh contains code is something like:

# code before
read -p "Password:" -s password
# code after

是否有可能有一个干净的单行?如果是这样,怎么会做呢?

Is it possible to have a clean one-liner? If so, how might one do it?

解决方法:

使用,而不是管道输出三个命令。

Use three commands instead of piping output.

卷曲-s https://raw.github.com/willfarrell/.vhosts/master/setup.sh -o vhosts.sh&放大器;&安培;庆典vhosts.sh&放大器;&安培; RM vhosts.sh

推荐答案

通过管道,在从标准输入(管道)读取,但已经看过外壳所有的标准输入,所以没有任何的阅读。

With the pipe, the read reads from standard input (the pipe), but the shell already read all the standard input so there isn't anything for the read to read.

这篇关于从卷曲管运行bash的时候读被跳过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆