zsh:funcs: Fix non-empty dir filter in bfs/find wrapper

The previous filter would filter out every non-regular file (e.g.
symbolic links).
This commit is contained in:
2025-03-28 16:19:02 +01:00
parent 0cb18dedef
commit b722b9aaec

View File

@@ -738,8 +738,8 @@ rmdir() {
# Make sure that std{out,err} are associated with a tty and that no # Make sure that std{out,err} are associated with a tty and that no
# arguments were passed that start with a dash # arguments were passed that start with a dash
if [[ -t 1 && -t 2 ]] && (( ! $# || ! ${@[(I)-*]} )); then if [[ -t 1 && -t 2 ]] && (( ! $# || ! ${@[(I)-*]} )); then
# Only print files and empty directories # Exclude non-empty directories
command bfs "$@" -type f -o -type d -empty command bfs "$@" -type d -not -empty -o -print
else else
command bfs "$@" command bfs "$@"
fi fi
@@ -754,9 +754,8 @@ rmdir() {
# Make sure that std{out,err} are associated with a tty and that no # Make sure that std{out,err} are associated with a tty and that no
# arguments were passed that start with a dash # arguments were passed that start with a dash
if [[ -t 1 && -t 2 ]] && (( ! $# || ! ${@[(I)-*]} )); then if [[ -t 1 && -t 2 ]] && (( ! $# || ! ${@[(I)-*]} )); then
# Only print files and empty directories (and mark these with a # Exclude non-empty directories and mark empty ones with a slash
# trailing slash) command find "$@" -type d \( -not -empty -o -printf "%p/\n" \) -o -print
command find "$@" -type f -print -o -type d -empty -printf "%p/\n"
else else
command find "$@" command find "$@"
fi fi