Fix ignore pattern search on empty ignore variable

The default ignore pattern would not be searched when the additional
variable was kept empty. This fixes it to always seach for the pattern,
regardless of any other variables.
This commit is contained in:
Marty Oehme 2020-01-30 13:21:01 +01:00
parent b702158b7c
commit bba4e1d71f

View file

@ -78,18 +78,20 @@ dryrun() {
printf "processing %s\n" "$d"
done
echo "Done printing directories ................................................."
}
is_ignored() {
IFS=":"
for ign in $ignore; do
# it is either passed in through our environment variable
# or it starts with a _ which is ignored by default (that's the regex).
# (using herestring to avoid cat>grep)
if [ "$ign" = "$1" ] || [ "$ign/" = "$1" ] || grep -q -e '^_[[:alnum:]]\{1,\}' <<<"$1"; then
if [ "$ign" = "$1" ] || [ "$ign/" = "$1" ]; then
return 0
fi
done
# or it starts with a _ which is ignored by default (that's the regex).
# (using herestring to avoid cat>grep)
if grep -q -e '^_[[:alnum:]]\{1,\}' <<<"$1"; then return 0; fi
return 1
}