From a3a1c4a5bd4914936ca7322c58e3ec0586104226 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 30 Jan 2020 12:51:48 +0100 Subject: [PATCH] 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. --- bootstrap/autostow.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bootstrap/autostow.sh b/bootstrap/autostow.sh index cbe0482..b7dd038 100755 --- a/bootstrap/autostow.sh +++ b/bootstrap/autostow.sh @@ -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\" " \ "" \ "" }