summaryrefslogtreecommitdiff
path: root/lib/keyringer/functions
diff options
context:
space:
mode:
Diffstat (limited to 'lib/keyringer/functions')
-rw-r--r--lib/keyringer/functions23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index dd0de03..22f16f8 100644
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -112,22 +112,23 @@ function keyringer_set_tmpfile {
exit 1
fi
- mkdir -p $BASEDIR/tmp
-
if [ -z "$1" ]; then
template="$BASEDIR/tmp/keyringer.XXXXXXXXXX"
else
template="$BASEDIR/tmp/$1.XXXXXXXXXX"
fi
- TMPFILE="`mktemp $template`" || exit 1
+ mkdir -p $BASEDIR/tmp
+ keyringer_git_ignore 'tmp/*'
+
+ tmpfile="`mktemp $template`"
if [ "$?" != "0" ]; then
- echo "Error: can't set tmpfile $TMPFILE"
+ echo "Error: can't set tmpfile $tmpfile"
exit 1
fi
- echo $TMPFILE
+ echo $tmpfile
}
# Remove a temporary file
@@ -143,3 +144,15 @@ function keyringer_unset_tmpfile {
exit 1
fi
}
+
+# Add a pattern into gitignore
+function keyringer_git_ignore {
+ if [ ! -z "$BASEDIR/.gitignore" ]; then
+ echo $1 > $BASEDIR/.gitignore
+ keyringer_exec git $BASEDIR add .gitignore
+ else
+ if ! grep -q -e "^$1$" $BASEDIR/.gitignore; then
+ echo $1 >> $BASEDIR/.gitignore
+ fi
+ fi
+}