summaryrefslogtreecommitdiff
path: root/bin/lt
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2023-02-24 18:00:32 +0100
committerMarc Vertes <mvertes@free.fr>2023-02-24 18:00:32 +0100
commit320cc91398a17f57da0296ffc64ddcbb64921df1 (patch)
treebc27f8a044ae636222dacc801c8afd5713aff906 /bin/lt
parentc8fb9352ac79d2ccf3dcdb352840b60e4dcc548a (diff)
customizations for slackware
Diffstat (limited to 'bin/lt')
-rwxr-xr-xbin/lt15
1 files changed, 11 insertions, 4 deletions
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