Bypassing prompt (to press return) in homebrew install script

心已入冬 提交于 2019-12-17 22:46:37

问题


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?


回答1:


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:

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



回答2:


This is what yes is for:

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



回答3:


Press enter 

if it asks to press return key

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

https://docs.brew.sh/



回答4:


Per the lead maintainer of Homebrew:

echo | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"



回答5:


This works fine for me,

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


来源:https://stackoverflow.com/questions/25535407/bypassing-prompt-to-press-return-in-homebrew-install-script

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