From 8066a2b222a31cf5ac217de5e26a267a2100940e Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 18 Apr 2014 12:57:45 +0200 Subject: Pruning: turns out rmdir does it for us with -p. --- src/password-store.sh | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/password-store.sh b/src/password-store.sh index 572ce2a..f80f026 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -114,12 +114,6 @@ reencrypt_path() { prev_gpg_recipients="${GPG_RECIPIENTS[@]}" done } -remove_empty_directories() { - local old_dir="$1" - while rmdir "$old_dir" &>/dev/null; do - old_dir="${old_dir%/*}" - done -} # # END helper functions @@ -281,7 +275,7 @@ cmd_init() { git rm -qr "$gpg_id" git_commit "Deinitialized ${gpg_id}." fi - remove_empty_directories "${gpg_id%/*}" + rmdir -p "${gpg_id%/*}" 2>/dev/null exit 0 fi @@ -545,7 +539,7 @@ cmd_delete() { git rm -qr "$passfile" git_commit "Removed $path from store." fi - remove_empty_directories "${passfile%/*}" + rmdir -p "${passfile%/*}" 2>/dev/null } cmd_copy_move() { @@ -593,7 +587,7 @@ cmd_copy_move() { git rm -qr "$old_path" git_add_file "$new_path" "Renamed ${1} to ${2}." fi - remove_empty_directories "$old_dir" + rmdir -p "$old_dir" 2>/dev/null else cp $interactive -r -v "$old_path" "$new_path" || exit 1 [[ -e "$new_path" ]] && reencrypt_path "$new_path" -- cgit v1.2.3