From 320cc91398a17f57da0296ffc64ddcbb64921df1 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 24 Feb 2023 18:00:32 +0100 Subject: customizations for slackware --- bin/lt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/lt b/bin/lt index f09f3b7..48424ef 100755 --- a/bin/lt +++ b/bin/lt @@ -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 -- cgit v1.2.3