PDA

View Full Version : No /bin/bash in OS X


DJSdotcom
04-08-2002, 12:30 AM
Well I've been trying to write some shell scripts using the standard:
#!/bin/bash
syntax at the beginning, and just figured out why it doesn't work. No matter WHAT you select in the Terminal preferences pane, or what you write down to use, you will never be able to use bash in OS X unless you download and make it yourself. Check it out for yourself, when it says what shell to use in the prefs, click on "your own shell", type in /bin/bash, and boom you're done... so you think. The next time a shell window opens up, the title may say /bin/bash, but if you ps -x, the last process will still say -tcsh!

mervTormel
04-08-2002, 01:00 AM
you can't order pizza if it isn't on the menu.

yeah, OSX don't come with bash, but your scripts should mostly work if your she-bang is changed to

#!/bin/sh

scripts shouldn't generally be written for bash and tcsh shells, as that makes them un-portable. #!/bin/bash is no standard.

you could also specify /foo/bar as the shell in terminal; it doesn't check.

bash and tcsh shells have a lot of features that are interactive, and don't translate to scripts.

you should generally write shell scripts in sh, which is most likely supported on every unix boxen you could find.

and it's relatively simple to implement bash in OSX...

finkify: http://fink.sourceforge.net/

honestpuck
04-08-2002, 04:13 AM
Originally posted by DJSdotcom
Well I've been trying to write some shell scripts using the standard:
#!/bin/bash
syntax at the beginning, and just figured out why it doesn't work. No matter WHAT you select in the Terminal preferences pane, or what you write down to use, you will never be able to use bash in OS X unless you download and make it yourself.
Well you don't have to download and make it yourself. Install fink (sourceforge.net/projects/fink/ (http://sourceforge.net/projects/fink/) ) and it will allow you to easily download and install 'bash' amongst a large number of other fine *nix open source tools. Highly recommended!

Tony

P.S. Most Unix programmers many years ago decided that '#!/bin/sh' was the correct thing to put. :)