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

问题描述 投票:21回答:5

非常简单的安装自制程序的脚本:

  #!/bin/bash

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

输出给出:

==> 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

如何在这样的脚本中按Enter键?会不会是最好的路线?

bash homebrew
5个回答
25
投票

读取https://raw.github.com/Homebrew/homebrew/go/install的源代码-仅在stdin是TTY时提示。如果您从/dev/null重定向标准输入,它根本不会提示。因此:

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

18
投票

这是yes的用途:

yes

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

如果要求按回车键

为了更加清楚,请获取啤酒文档

Press enter 

0
投票

https://docs.brew.sh/

Per the lead maintainer of Homebrew

0
投票

这对我来说很好,

echo | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.