From b722b9aaecd8803ff316952955df0c844cbb854d Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Fri, 28 Mar 2025 16:19:02 +0100 Subject: [PATCH] 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). --- .config/zsh/zshrc.d/40-functions.zsh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.config/zsh/zshrc.d/40-functions.zsh b/.config/zsh/zshrc.d/40-functions.zsh index 881539d..37bba32 100644 --- a/.config/zsh/zshrc.d/40-functions.zsh +++ b/.config/zsh/zshrc.d/40-functions.zsh @@ -738,8 +738,8 @@ rmdir() { # Make sure that std{out,err} are associated with a tty and that no # arguments were passed that start with a dash if [[ -t 1 && -t 2 ]] && (( ! $# || ! ${@[(I)-*]} )); then - # Only print files and empty directories - command bfs "$@" -type f -o -type d -empty + # Exclude non-empty directories + command bfs "$@" -type d -not -empty -o -print else command bfs "$@" fi @@ -754,9 +754,8 @@ rmdir() { # Make sure that std{out,err} are associated with a tty and that no # arguments were passed that start with a dash if [[ -t 1 && -t 2 ]] && (( ! $# || ! ${@[(I)-*]} )); then - # Only print files and empty directories (and mark these with a - # trailing slash) - command find "$@" -type f -print -o -type d -empty -printf "%p/\n" + # Exclude non-empty directories and mark empty ones with a slash + command find "$@" -type d \( -not -empty -o -printf "%p/\n" \) -o -print else command find "$@" fi