diff --git a/lib/ulib/base b/lib/ulib/base index 250087f..13e7e52 100644 --- a/lib/ulib/base +++ b/lib/ulib/base @@ -824,7 +824,9 @@ function update_link() { # c'est un lien relatif, faire un lien relatif dest="$(relpath "$1" "$linkdir")" fi - if [ -d "$link" ]; then + if [ "$dest" == "$ldest" ]; then + : # pas besoin de mettre à jour + elif [ -d "$link" ]; then rm -f "$link" && ln -s "$dest" "$link" else ln -sf "$dest" "$link" @@ -837,14 +839,17 @@ function move_link() { [ -n "$1" -a -n "$2" ] || return 1 local link="$1" dest="$2" [ -d "$dest" ] && dest="$dest/$(basename -- "$link")" + dest="$(abspath "$dest")" if [ -L "$link" ]; then link="$(abspath "$link")" linkdir="$(dirname -- "$link")" ldest="$(readlink "$link")" ldest="$(abspath "$ldest" "$linkdir")" + [ "$dest" == "$link" ] && return 1 mv "$link" "$dest" || return 1 update_link "$ldest" "$dest" else + [ "$dest" == "$link" ] && return 1 mv "$link" "$dest" fi } @@ -889,7 +894,7 @@ function move_file() { local src="$1" dest="$2" link shift; shift [ -d "$dest" ] && dest="$dest/$(basename -- "$src")" - move_link "$src" "$dest" || return + move_link "$src" "$dest" || return 1 for link in "$@"; do update_link "$dest" "$link" done