Backward compatibility of shell scripts

command line

I use a .command file to start a basic shell script in the form:

#!/bin/bash
-- this simply starts Something at /usr/local/bin/Something
myLittleOneLineScript

To make it work I changed its permissions and made it executable.

The question is: I run the latest Mac OS X version and this script perfectly works. But: will it work in any previous OS X version?

Best Answer

"Will it work" has two aspects here:

  • will executing the binary work?
  • is bash capable of running the script as such.

The example looks fairly basic as far as shell scripting is concerned. So yes, it should work with previous OSX versions of bash. It would (as long as Something is installed in /usr/local/bin) even work in quite old versions of the Bourne Shell (/bin/sh) on various Unix systems.