问题
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