summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Mike Burns <mike@mike-burns.com>2013-08-11 15:38:06 +0200
committerGravatar Mike Burns <mike@mike-burns.com>2013-08-11 15:38:06 +0200
commit63ab42206f25e181f626ec0c7ddad045fa27846c (patch)
tree6b9ea930409ac57023b5bba71d9de12ee51d93db
parent5319a8038ef4fa1f716e33fad6628d8737ddcef0 (diff)
rcdn only removes symlinks
Picture this case: % ls -l ~/.a ~/.a -> ~/.dotfiles/a % tree ~/.dotfiles/a a `-- b `-- c `-- d `-- foo Ideally we would want `~/.a/b/c/d/foo` to be the symlink, and the rest to be actual directories. However, some people did it differently. Running `rcdn` on the above would previously have removed `foo` from `~/.dotfiles`. Now, it removes `~/.a` and nothing more.
-rwxr-xr-xbin/rcdn17
-rw-r--r--man/rcdn.12
2 files changed, 16 insertions, 3 deletions
diff --git a/bin/rcdn b/bin/rcdn
index a7fb81d..99812aa 100755
--- a/bin/rcdn
+++ b/bin/rcdn
@@ -3,6 +3,20 @@
: ${RCM_LIB:=`dirname $0`/../share/rcm}
. $RCM_LIB/rcm.sh
+remove_link() {
+ local dest=$1
+ local original=$2
+
+ if [ x$dest = "x/" ]; then
+ $VERBOSE "not a symlink, skipping: $original"
+ elif [ -L $dest ]; then
+ $RM -rf $dest
+ rmdir -p `dirname $original` 2>/dev/null
+ else
+ remove_link `dirname $dest` $original
+ fi
+}
+
handle_command_line() {
local arg_tags=
local verbosity=0
@@ -58,6 +72,5 @@ for dest_and_src in `lsrc $LS_ARGS`; do
dest=`echo $dest_and_src | sed 's/:.*//'`
src=`echo $dest_and_src | sed 's/.*://'`
- $RM -rf $dest
- rmdir -p `dirname $dest` 2>/dev/null
+ remove_link $dest $dest
done
diff --git a/man/rcdn.1 b/man/rcdn.1
index 9007783..d61707e 100644
--- a/man/rcdn.1
+++ b/man/rcdn.1
@@ -13,7 +13,7 @@
.Op Fl t Ar tag
.Op Ar files ...
.Sh DESCRIPTION
-This program will remove all the rc files that the
+This program will remove all the rc file symlinks that the
.Xr rcm 7
suite knows about. This can be further controlled with the
.Fl t