bash 在自制软件安装脚本中绕过提示(按回车键)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25535407/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 11:14:52  来源:igfitidea点击:

Bypassing prompt (to press return) in homebrew install script

bashhomebrew

提问by cakes88

Very simple script that installs homebrew:

安装自制软件的非常简单的脚本:

  #!/bin/bash

  ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

The output gives:

输出给出:

==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1

Press RETURN to continue or any other key to abort

How do I press enter in a script like this? Would expect be the best route?

如何在这样的脚本中按 Enter 键?期望是最好的路线吗?

回答by Charles Duffy

Reading the source of https://raw.github.com/Homebrew/homebrew/go/install-- it only prompts if stdin is a TTY. If you redirect stdin from /dev/null, it won't prompt at all. So:

阅读https://raw.github.com/Homebrew/homebrew/go/install的源代码——它只提示 stdin 是否为 TTY。如果您从 重定向 stdin /dev/null,它根本不会提示。所以:

ruby \
  -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" \
  </dev/null

回答by l0b0

This is what yesis for:

yes是为了:

yes '' | ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

回答by vibi2605

Press enter 

if it asks to press return key

如果它要求按回车键

For more clarity of this,get hold of the brew docs

为了更清楚地了解这一点,请获取 brew 文档

https://docs.brew.sh/

回答by eddies

Per the lead maintainer of Homebrew:

根据 Homebrew 的主要维护者

echo | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

回答by Sazzad Hissain Khan

This works fine for me,

这对我来说很好用,

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null