diff options
Diffstat (limited to 'bin/lt')
| -rwxr-xr-x | bin/lt | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -2,7 +2,7 @@ # link tree -lt_version='lt-0.1' +lt_version='lt-0.2' unset CDPATH export LC_ALL=C IFS=' ' @@ -15,7 +15,8 @@ Usage: Options: -V print version and exit - -n print actions but not execute" + -n print actions but not execute + -u unlink" } # ca returns the common ancestor between 2 paths @@ -65,14 +66,20 @@ lt() { done f=${f#./}; fd=$d/$f; fd=${fd%/*} test -d "$fd" || $trace mkdir -p "$fd" - rp "$s/$f" "$d/$f" && $trace ln -sf "$R1" "$d/$f" + if [ "$unlink" ]; then + ! [ -L "$d/$f" ] && echo "not a symlink: $d/$f" >&2 && continue + $trace rm "$d/$f" + else + rp "$s/$f" "$d/$f" && $trace ln -sf "$R1" "$d/$f" + fi done } } -while getopts :nvV opt; do +while getopts :nuvV opt; do case $opt in (n) trace='echo' ;; + (u) unlink=1 ;; (V) echo "$lt_version"; exit ;; (*) help; exit 1;; esac |
