Apple - How to set alternatives in 10.8?

I understand the motivation behind your question. update-alternatives elegantly solves the problem of managing several installed versions of a program (for example Java) or different ports of a program (vim vs. elvis vs. vile) by making one of them the default one.

update-alternatives, found in many Linux distros, creates and manages a set of symlinks from /bin, /usr/bin (and the like) to /etc/alternatives, and from there to the location where the program is installed.

For example, in openSUSE java is symlinked to /etc/alternatives/java, which is symlinked to a "private" path where java resides:

/usr/bin/java -> /etc/alternatives/java
/etc/alternatives/java -> /usr/lib64/jvm/java-1.5.0-sun-1.5.0/jre/bin/java

Unfortunately, and although some think it would be necessary, at least for MacPorts, there is no such thing in OS X. I have personally solved the lack of update-alternatives with aliases in my .bashrc:

alias ls='/usr/local/bin/ls'

or simply changing $PATH:

PATH=/usr/local/bin:$PATH

If you can't solve it like this and are weighing the fact of porting it to OS X be aware that although update-alternatives' first incarnation was a Perl script, it was rewritten in C for Debian, and some other distros adopted it later (for instance openSUSE 12.1).

openSUSE 11.4 provides the Perl version as an RPM package. If you are looking for the C version, go for any recent Ubuntu or Debian release, or openSUSE 12.1 or later.