mirror of
https://github.com/Matir/skel.git
synced 2026-05-25 21:19:09 -07:00
Prune broken symlinks now confirms.
This commit is contained in:
@@ -1,4 +1,26 @@
|
|||||||
prune-broken-symlinks() {
|
prune-broken-symlinks() {
|
||||||
setopt localoptions nounset
|
setopt localoptions nounset
|
||||||
find $1 -type l -xtype l -print -delete
|
local ASK
|
||||||
|
local DIR
|
||||||
|
local FINDCMD
|
||||||
|
local i
|
||||||
|
|
||||||
|
if [[ "${1:-}" == "-y" ]] ; then
|
||||||
|
ASK=0
|
||||||
|
shift
|
||||||
|
else
|
||||||
|
ASK=1
|
||||||
|
fi
|
||||||
|
DIR=${1:-.}
|
||||||
|
FINDCMD=(find ${DIR} -type l -xtype l)
|
||||||
|
if (($ASK)) ; then
|
||||||
|
${FINDCMD} -print
|
||||||
|
echo -n 'Delete these links? [y/n] '
|
||||||
|
if read -q ; then
|
||||||
|
${FINDCMD} -delete
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
${FINDCMD} -print -delete
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user