summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2010-09-03 17:17:15 -0300
committerSilvio Rhatto <rhatto@riseup.net>2010-09-03 17:17:15 -0300
commit3c29eaf7ffd39f82e63cba2c2bcf850f3c047fff (patch)
tree97c2f2d2f00069b1ef2a9514860ce454ec72fb9f /lib
parentb593d116a1ab03df5536f3285a741eb9ef71058a (diff)
downloadkeyringer-3c29eaf7ffd39f82e63cba2c2bcf850f3c047fff.tar.gz
keyringer-3c29eaf7ffd39f82e63cba2c2bcf850f3c047fff.tar.bz2
Adding edit command
Diffstat (limited to 'lib')
-rw-r--r--lib/keyringer/functions39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index add22e2..dd0de03 100644
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -104,3 +104,42 @@ function keyringer_is_git {
fi
fi
}
+
+# Setup a temporary file
+function keyringer_set_tmpfile {
+ if [ -z "$BASEDIR" ]; then
+ echo "Please set BASEDIR before creating a tmp file"
+ 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
+
+ if [ "$?" != "0" ]; then
+ echo "Error: can't set tmpfile $TMPFILE"
+ exit 1
+ fi
+
+ echo $TMPFILE
+}
+
+# Remove a temporary file
+function keyringer_unset_tmpfile {
+ if [ -z "$1" ]; then
+ echo "No tmp file set"
+ fi
+
+ rm -f $1
+
+ if [ "$?" != "0" ]; then
+ echo "Warning: could not delete file $1. Please delete it manually as it might have sensitive information."
+ exit 1
+ fi
+}