readlink.sh
is a pure shell implementation that uses dirname
, basename
, readlink
and pwd
utils.
Note that you cannot rename it to just readlink
as then the script will call itself instead of the system utility.
realpath
script simply calls Python's os.path.realpath
.
Python is provided in OS X and major Linux distributions.
You can use instead of the system utility by making a symlink: ln -s realpath readlink
.
Another way is to install coreutils
package via Homebrew or MacPorts and use greadlink
.
The code is taken from the following page on StackOverflow: http://goo.gl/Yw9OY
I use the following script to create symlinks for my precious GNU packages on MacOS.
It checks every executable in
/bin
&/usr/bin
if there is GNU alternative for it, and if it is, creates symlink in/usr/local/bin
.Also, note the
echo
at line 23 (functionprocess-executable
,then
statement). DO NOT remove it on the first (dry) run. Check what the script outputs. Only then you are allowed to remove it.