From 3c29eaf7ffd39f82e63cba2c2bcf850f3c047fff Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 3 Sep 2010 17:17:15 -0300 Subject: Adding edit command --- lib/keyringer/functions | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) 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 +} -- cgit v1.2.3