On Linux-based systems whenever I need to use the following command:
#!/bin/bash
BASEDIR=$(dirname "$0")
echo $BASEDIR
I have however read in different places that $(dirname "$0")
is not supported by Mac OS X systems and BSD-based systems (apparently both based on Unix).
I saw some alternatives, but all of them always have a criticism, or some mention saying they fail at something.
What I need to know is there any way to get the current script directory in a cross-platfom (unix-like) way?
Another thing, I'd like to know how to get both the actual directory path and the path of a symbolic link.
Note: No need to be with
bash