rmdir-empty: do the first level directories first

This commit is contained in:
neingeist 2023-12-09 13:08:48 +01:00
parent 0f8c9c5b68
commit ba0030d418

View file

@ -7,9 +7,11 @@ rmdir_empty() {
set -- . set -- .
fi fi
find "$@" -depth \ # do the first level directories first
-path "." -prune -or \ for maxdepth_opt in "-maxdepth 1" ""; do
-type d -empty -exec rmdir -v {} \; find "$@" -depth -mindepth 1 $maxdepth_opt \
-type d -empty -exec rmdir -v {} \;
done
} }
rmdir_empty "$@" rmdir_empty "$@"