From 4d6456054b3984c65f5ccc275c0dd6cd7cf1a08c Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Mon, 11 Apr 2022 11:48:12 +0000 Subject: [PATCH] bin: adjust rd to always clean empty dirs and files --- .local/bin/scripts/= | 2 +- .local/bin/scripts/rd | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.local/bin/scripts/= b/.local/bin/scripts/= index 6554a52..0da6cef 100755 --- a/.local/bin/scripts/= +++ b/.local/bin/scripts/= @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Shortcut for mathematical calculations # Assumes german numbers as in 1.000,5 calc="$(echo "$@" | sed -e 's/p/+/g' -e 's/\.//g' -e 's/,/./g' -e 's/x/*/g' -e 's/m/-/g')" diff --git a/.local/bin/scripts/rd b/.local/bin/scripts/rd index 72d17f6..cad4375 100755 --- a/.local/bin/scripts/rd +++ b/.local/bin/scripts/rd @@ -10,14 +10,15 @@ do then echo -n "Force delete git project $f? " read answer test "$answer" = "y" && - $elevate rm -rf "$f" - else - $elevate find "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 3) -not -name .stfolder \( -type d -o -type f \) -a -empty -printf 'Removing empty %p\n' -delete - test $# -eq 0 && exit $? - if test -e "$f"; then - echo -n "$f ($(ls -A "$f" | head -3 | paste -s -d' ')) " >&2 && - $elevate rm -rI "$f" - fi + $elevate rm -rf "$f" && + exit + fi + + $elevate find "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 3) -not -name .stfolder \( -type d -o -type f \) -a -empty -printf 'Removing empty %p\n' -delete + test $# -eq 0 && exit $? + if test -e "$f"; then + echo -n "$f ($(ls -A "$f" | head -3 | paste -s -d' ')) " >&2 && + $elevate rm -rI "$f" fi else $elevate rm -i "$f" fi