1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-05-18 17:53:23 -07:00
rc/sh/is_empty
Connor Olding d5f3f14d72 merge compatibility lines
RIP meaningful last-modified dates
2024-03-26 15:08:14 -07:00

15 lines
394 B
Bash
Executable File

#!/usr/bin/env bash
# YES_ZSH YES_BASH NO_DASH NO_ASH
is_empty() { ### @-
### return 0 if the directory given by argument is empty.
while read -r f; do
[ ! -d "$f" ] && [ -s "$f" ] && return 1
done < <(find ${1:-.})
# TODO: done < <(find ${1:-.} -type f -print -quit)
# this needs to skip empty files as well.
return 0
}
[ -n "${preload+-}" ] || is_empty "$@"