Only run readlink on a symlink on OS X

readlink does not print anything if the argument is not actually
a symlink. This change allows running the tool from the current
directory with `./qira`.
This commit is contained in:
Rainer Müller 2016-03-30 18:09:08 +02:00
parent 1f62559134
commit a243851eff
1 changed files with 5 additions and 1 deletions

6
qira
View File

@ -3,7 +3,11 @@ unamestr=$(uname)
if [[ "$unamestr" == 'Linux' ]]; then if [[ "$unamestr" == 'Linux' ]]; then
DIR=$(dirname $(readlink -f $0)) DIR=$(dirname $(readlink -f $0))
elif [[ "$unamestr" == "Darwin" ]]; then elif [[ "$unamestr" == "Darwin" ]]; then
DIR=$(dirname $(readlink $(which $0))) cmd=$(which "$0")
if [ -L "$cmd" ]; then
cmd=$(readlink "$cmd")
fi
DIR=$(dirname "$cmd")
else else
echo "Only Linux and Mac OS X are supported!" echo "Only Linux and Mac OS X are supported!"
exit exit