Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Homebrew via shell script

This must be an easy one. I'd like to install Homebrew via a shell script on OS X.

Homebrew's recommended installation from the terminal works,

$ ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go)

but if I put the following in a file test.sh,

#!/bin/sh
ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go)

then execute it,

$ sh test.sh

I receive the following error:

test.sh: line 2: syntax error near unexpected token `('
test.sh: line 2: `ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go)'

What is the correct syntax to use in a shell script to get this to work and why is it different from the command line? Thanks!

like image 504
Wes Avatar asked Apr 29 '26 15:04

Wes


1 Answers

It's complaining because sh doesn't have that syntax, but bash does. Use #!/bin/bash instead.

Also, no need to use the sh command to execute shell scripts (that's the whole point of putting the hashbang!). Just chmod +x script.sh and invoke with ./script.sh

like image 168
jli Avatar answered May 02 '26 15:05

jli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!