Add autostow.sh ignore pattern to underscore dirs

autostow.sh will automatically ignore any directories it finds that
begin with an underscore. This will make it possible to remove the
default entires of AUTOSTOW_IGNORED_DIRS variable and thus remove some
of the magic and make autostow.sh behavior more predictable.
This commit is contained in:
Marty Oehme 2020-01-30 12:51:48 +01:00
parent 4dfb9767ee
commit a3a1c4a5bd

View file

@ -83,7 +83,10 @@ dryrun() {
is_ignored() {
IFS=":"
for ign in $ignore; do
if [ "$ign" == "$1" ] || [ "$ign/" == "$1" ]; then
# 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
return 0
fi
done
@ -115,7 +118,9 @@ usage() {
"" \
" -n | --dry-run Do not invoke any operation but print out directories affected, simulating a dry-run." \
"" \
" -d Remove dotfiles, by unlinking any directory found next to stow.sh using GNU stow." \
" Note, by default any directory starting with an underscore _directoryname will be ignored." \
" Additional folders to ignore can be set through the environment variable AUTOSTOW_IGNORED_DIRS " \
" using a colon-separated string: AUTOSTOW_IGNORED_DIRS=\"directories:to:ignore\" " \
"" \
""
}