What does this line from Homebrew mean?
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
I understand -e
will include ruby code in command but I don't get the $()
part. What's the dollar sign bracket doing here?
And very importantly, where can I find the documentation for this?
$(...) is Bash command substitution. It happens before the command is executed; it executes the command inside the parentheses and substitutes its output. For example,
echo "There are $(ls | wc -l) files in this directory"
will first execute ls | wc -l
which will output e.g. 17
; then echo "There are 17 files in this directory"
.
curl
is a command-line utility that fetches the contents at an URL and outputs that content, by default. Thus, /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)
will first download the contents of https://raw.githubusercontent.com/Homebrew/install/master/install , then substitute it into the command line as the parameter of the -e
option. Ruby will then execute it as Ruby code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With