diff options
| author | Silvio Rhatto <rhatto@riseup.net> | 2010-09-03 17:17:15 -0300 | 
|---|---|---|
| committer | Silvio Rhatto <rhatto@riseup.net> | 2010-09-03 17:17:15 -0300 | 
| commit | 3c29eaf7ffd39f82e63cba2c2bcf850f3c047fff (patch) | |
| tree | 97c2f2d2f00069b1ef2a9514860ce454ec72fb9f /lib | |
| parent | b593d116a1ab03df5536f3285a741eb9ef71058a (diff) | |
| download | keyringer-3c29eaf7ffd39f82e63cba2c2bcf850f3c047fff.tar.gz keyringer-3c29eaf7ffd39f82e63cba2c2bcf850f3c047fff.tar.bz2  | |
Adding edit command
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/keyringer/functions | 39 | 
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 +}  | 
