aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2010-09-18 14:00:20 -0300
committerSilvio Rhatto <rhatto@riseup.net>2010-09-18 14:00:20 -0300
commit3ef42ced45817c3fbd0c5247edfd06f1598e1d78 (patch)
tree2df586edb7c883eab0db7ba30aad1e8f84934b60
parentecfeeb99a3bb291d271f669c4c10c3fae7246227 (diff)
downloadkeyringer-3ef42ced45817c3fbd0c5247edfd06f1598e1d78.tar.gz
keyringer-3ef42ced45817c3fbd0c5247edfd06f1598e1d78.tar.bz2
New function keyringer_get_new_file
-rw-r--r--lib/keyringer/functions10
-rwxr-xr-xshare/keyringer/encrypt8
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index 9c37291..67bbc50 100644
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -213,6 +213,16 @@ function keyringer_get_file {
fi
}
+# Get a new file argument
+function keyringer_get_new_file {
+ FILE="`keyringer_filename $1`"
+
+ if [ -z "$FILE" ]; then
+ keyringer_action_usage
+ exit 1
+ fi
+}
+
# Run the action usage
function keyringer_action_usage {
if [ "`type -t "keyringer_usage_$BASENAME"`" == "function" ]; then
diff --git a/share/keyringer/encrypt b/share/keyringer/encrypt
index 26b2710..b6d594c 100755
--- a/share/keyringer/encrypt
+++ b/share/keyringer/encrypt
@@ -8,13 +8,7 @@ LIB="`dirname $0`/../../lib/keyringer/functions"
source $LIB || exit 1
# Aditional parameters
-FILE="`keyringer_filename $2`"
-
-# Setup
-if [ -z "$FILE" ]; then
- echo "Usage: keyringer <keyring> `basename $0` <file>"
- exit 1
-fi
+FILE="`keyringer_get_new_file $2`"
# Encrypt
mkdir -p $KEYDIR/`dirname $FILE`