Closed leto closed 5 years ago
Ahh, likely because MacOS has outdated BSD coreutils by default not up to date GNU coreutils.
-f
gives the absolute path incase the symlink was set with a relative path:
lukechilds@notarynode-ar:~$ ln -sf ../bar foo
lukechilds@notarynode-ar:~$ readlink foo
../bar
lukechilds@notarynode-ar:~$ readlink -f foo
/home/bar
which is what we want. Relative path is relative to the symlink not the current working directory, so you can't cd
directly to it.
cd
ing to the source first and then to the relative readlink should work on both MacOS and Linux for relative and absolute symlinks.
Something like:
cd "$( dirname "${BASH_SOURCE[0]}" )"
cd "$( dirname "$( readlink "${BASH_SOURCE[0]}" )" )"
Not tested but should work.
If there's no symlink the second line should just resolve to cd .
so won't negatively affect anything.
OS X is dumb:
This somehow doesn't lead to startup failure, only appears to be a warning?
@lukechilds suggestion?