summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorP. 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)
commitbfd98708d4d91d9b3f92f1a6179f9bb6d5141739 (patch)
tree379cd7319171edaae0fbde4d7a0e7b5e5798d49e /lib
parentdb4273ef349f556a1b65926200668ab5e467110d (diff)
dir_is_empty(): Accept exclusion arguments
Diffstat (limited to 'lib')
-rw-r--r--lib/dir.sh15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/dir.sh b/lib/dir.sh
index f6b6710..c49469d 100644
--- a/lib/dir.sh
+++ b/lib/dir.sh
@@ -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