zsh:bfs(): Make sure that std{out,err} are ttys

When piping its output, I want the normal behaviour.

Also swap the if and else branches for better readability.
This commit is contained in:
2025-02-05 16:44:38 +01:00
parent f60d25e47c
commit ed2b9e760c

View File

@@ -750,11 +750,12 @@ rmdir() {
(( ! $+commands[bfs] )) || bfs() { (( ! $+commands[bfs] )) || bfs() {
emulate -L zsh emulate -L zsh
# Check if arguments were passed that start with a dash # Make sure that std{out,err} are associated with a tty and that no
if (( $# && ${@[(I)-*]} )); then # arguments were passed that start with a dash
command bfs "$@" if [[ -t 1 && -t 2 ]] && (( ! $# || ! ${@[(I)-*]} )); then
else
# Only print files and empty directories # Only print files and empty directories
command bfs "$@" -type f -o -type d -empty command bfs "$@" -type f -o -type d -empty
else
command bfs "$@"
fi fi
} }