Support ~ in add_patterns for git-ignore

This commit is contained in:
CJ 2015-03-11 14:59:42 +08:00
parent bf89063212
commit 522213a28f

View file

@ -29,9 +29,10 @@ function add_local {
function add_patterns {
echo "Adding pattern(s) to: $1"
local file="${1/#~/$HOME}"
for pattern in "${@:2}"; do
echo "... adding '$pattern'"
(test -f "$1" && test "$pattern" && grep -q "$pattern" "$1") || echo "$pattern" >> "$1"
(test -f "$file" && test "$pattern" && grep -q "$pattern" "$file") || echo "$pattern" >> "$file"
done
}