From bfd98708d4d91d9b3f92f1a6179f9bb6d5141739 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 11 Nov 2014 23:17:50 -0500 Subject: dir_is_empty(): Accept exclusion arguments --- 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 -- cgit v0.9.1