diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dir.sh | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -26,6 +26,9 @@ dir_is_empty() local dir="${1}" local ret= local dirent= + local exclude= + local exclusion= + shift 1 ret=0 @@ -36,7 +39,17 @@ dir_is_empty() # .??* dirents whose names start with "." and are three or more # characters long for dirent in "${dir}/"* "${dir}/".[!.] "${dir}/".[!.] "${dir}/".??*; do - if [ -e "${dirent}" ]; then + if ! [ -e "${dirent}" ]; then + continue + fi + exclude=false + for exclusion in "${@}"; do + if [ "x${dirent##*/}" = "x${exclusion}" ]; then + exclude=true + break + fi + done + if ! ${exclude}; then ret=1 break fi |