2021-09-16 12:18:26 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Remove recursively safely
|
2021-11-09 04:37:07 +00:00
|
|
|
case "$1" in ([0-9]) depth=$1; shift;; esac
|
2021-09-16 12:18:26 +00:00
|
|
|
for f in "$@"
|
|
|
|
do
|
2021-10-04 08:46:40 +00:00
|
|
|
test -w "$f" && elevate="" || elevate=sudo
|
2021-09-16 12:18:26 +00:00
|
|
|
if test -d "$f"; then
|
|
|
|
if test -e "$f/.git" || test -e "$f/packed-refs"
|
2021-11-17 14:56:16 +00:00
|
|
|
then echo -n "Force delete git project $f? "
|
2021-09-16 12:18:26 +00:00
|
|
|
read answer
|
2021-11-23 13:56:38 +00:00
|
|
|
test "$answer" = "y" &&
|
|
|
|
$elevate rm -rf "$f"
|
2021-12-09 11:27:33 +00:00
|
|
|
else find "$f" -maxdepth 4 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete
|
2021-11-23 13:56:38 +00:00
|
|
|
test -e "$f" &&
|
|
|
|
echo -n "$f ($(ls -A $f | head -3 | paste -s -d' ')) " >&2 &&
|
|
|
|
$elevate rm -rI "$f"
|
2021-09-16 12:18:26 +00:00
|
|
|
fi
|
2021-10-04 08:46:40 +00:00
|
|
|
else $elevate rm -i "$f"
|
2021-09-16 12:18:26 +00:00
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|