How to associate /opt/local/bin/bash with .bat files

Clemens Lang cal at
Tue Jan 28 05:40:15 PST 2014


On Tue, Jan 28, 2014 at 07:23:22AM -0600, David Favor wrote:
> Can someone point me to the docs that describe how to associate Mac
> files (like .bat) with the MacPorts version of bash.

Macs (and other Unix systems) don't associate files and their
interpreters based on the filename extension. Only windows uses this

Instead, a method called the "shebang" is used for script files. The
first line in the file you're trying to execute should be in the form of

Editing your script and making the first line
should cause MacPorts bash to be used to execute the script. Another
common method is using /usr/bin/env, which in turn uses $PATH to
determine which binary to use:
  #!/usr/bin/env bash

Note that .bat scripts are usually written for windows shell and will
not work with bash on OS X (but you'll probably notice that, if your
script doesn't work).

Further reading:

Clemens Lang

More information about the macports-users mailing list