Fix #127 git-ignore won't add duplicates.

As per the bug identified in #127 git-ignore would add duplicate entries in .gitignore which is redundant and should not happen.
grep will suitably verify that the entry doesn't exit but only if the file actually exists or we will get an error on stderr. check if the
file exists with test -f and that the new entry is present or alternatively just go ahead and add the new value which will create the file if it didn't exist.
Running the same command again does not add the duplicate.
This commit is contained in:
nickl- 2012-07-21 13:34:35 +02:00
parent ca7579e774
commit 7398d10bd4

View file

@ -5,6 +5,6 @@ if test $# -eq 0; then
else
for pattern in $@; do
echo "... adding '$pattern' to .gitignore"
echo $pattern >> .gitignore
(test -f .gitignore && grep -q $pattern .gitignore) || echo $pattern >> .gitignore
done
fi