diff options
author | P. J. McDermott <pj@pehjota.net> | 2014-11-11 23:17:50 (EST) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2014-11-11 23:17:50 (EST) |
commit | bfd98708d4d91d9b3f92f1a6179f9bb6d5141739 (patch) | |
tree | 379cd7319171edaae0fbde4d7a0e7b5e5798d49e | |
parent | db4273ef349f556a1b65926200668ab5e467110d (diff) |
dir_is_empty(): Accept exclusion arguments
-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 |