Handle relative symlinks correctly

This commit is contained in:
Juan Cruz Viotti 2015-03-03 13:52:18 -04:00
parent d449b0bb52
commit 8ce27d2f6d

View File

@ -39,13 +39,19 @@ while [ -L "$BIN_RESIN" ]; do
BIN_RESIN=`readlink "$BIN_RESIN"`
done
# If a link was resolved (ie BIN_RESIN != $0) and the resolved link is relative,
# we assume the link is relative to the dirname of the link location
if [[ "$BIN_RESIN" != "$0" ]] && [[ "$BIN_RESIN" != /* ]]; then
BIN_RESIN=`dirname $0`/$BIN_RESIN
fi
BIN_DIRECTORY=`dirname $BIN_RESIN`
NODE_PATH=$BIN_DIRECTORY/node/$NODE_BIN
if [ ! -x $NODE_PATH ]; then
echo "$NODE_PATH does not exist"
echo "Warning: $NODE_PATH does not exist"
# As a last resource, try to use an already available node
if command -v node >/dev/null 2>&1; then