colinmollenhour/modman

undeploy fails because of symlink

technik-vitafy opened this issue · 1 comments

Hi,

I'm facing the following problem:
I created some symlinks in the magento folder which produces errors when running an undeploy.
Let's look at an example. There is the following symlink:
/srv/www/releases/20160204104433/htdocs/app/etc/local.xml -> /srv/www/shared/htdocs/app/etc/local.xml

When running an undeploy command:
./scripts/bin/modman undeploy m2e-pro

The following error is thrown:
./scripts/bin/modman: line 394: cd: /srv/www/releases/20160204104433/htdocs/app/etc//srv/www/shared/htdocs/app/etc: No such file or directory

As you can see two paths are concatenated which is wrong.

The responsible code is:

`get_abs_filename() {

if [ -d "$(dirname "$1")" ]; then
echo "$(cd "$(dirname "$1")/$(dirname "$(readlink "$1")")" && pwd)/$(basename "$1")"
fi
}

I changed the code:

`get_abs_filename() {

if [ -d "$(dirname "$1")" ]; then
SOURCE="$1"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
echo DIR
fi
}
`

I used the code from http://stackoverflow.com/a/246128/4891696

Could you please verify if this is right and think about merging it into your next release?

Thank's and best regards,
Chris

It certainly seems like you found a bug, so please submit as a PR. Thanks