From 4d85c40d8ac5140835c5f75d513f886ae5910da9 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 18 Sep 2010 12:40:56 -0300 Subject: Making code that checks for file argument as a common function --- share/keyringer/append | 12 ++---------- share/keyringer/decrypt | 12 ++---------- share/keyringer/del | 13 ++----------- share/keyringer/edit | 12 +++--------- share/keyringer/recrypt | 12 ++---------- 5 files changed, 11 insertions(+), 50 deletions(-) (limited to 'share') diff --git a/share/keyringer/append b/share/keyringer/append index fbfe49f..309f88c 100755 --- a/share/keyringer/append +++ b/share/keyringer/append @@ -8,16 +8,8 @@ LIB="`dirname $0`/../../lib/keyringer/functions" source $LIB keyringer_set_env $* -# Aditional parameters -FILE="`keyringer_filename $2`" - -if [ -z "$FILE" ]; then - echo "Usage: keyringer `basename $0` " - exit 1 -elif [ ! -f "$KEYDIR/$FILE" ]; then - echo "File not found: $KEYDIR/$FILE" - exit 1 -fi +# Get file +keyringer_get_file $2 OLDIFS=$IFS IFS=$'\n' diff --git a/share/keyringer/decrypt b/share/keyringer/decrypt index cb1d35b..71367f5 100755 --- a/share/keyringer/decrypt +++ b/share/keyringer/decrypt @@ -8,15 +8,7 @@ LIB="`dirname $0`/../../lib/keyringer/functions" source $LIB keyringer_set_env $* -# Aditional parameters -FILE="`keyringer_filename $2`" - -if [ -z "$FILE" ]; then - echo "Usage: keyringer `basename $0` " - exit 1 -elif [ ! -f "$KEYDIR/$FILE" ]; then - echo "File not found: $KEYDIR/$FILE" - exit 1 -fi +# Get file +keyringer_get_file $2 gpg --quiet --use-agent -d $KEYDIR/$FILE diff --git a/share/keyringer/del b/share/keyringer/del index c699394..d8ed68f 100755 --- a/share/keyringer/del +++ b/share/keyringer/del @@ -8,17 +8,8 @@ LIB="`dirname $0`/../../lib/keyringer/functions" source $LIB keyringer_set_env $* -# Aditional parameters -FILE="`keyringer_filename $2`" - -# Setup -if [ -z "$FILE" ]; then - echo "Usage: keyringer `basename $0` " - exit 1 -elif [ ! -f "$KEYDIR/$FILE" ]; then - echo "File not found: $KEYDIR/$FILE" - exit 1 -fi +# Get file +keyringer_get_file $2 # Remove if [ -d "$KEYDIR/.git" ]; then diff --git a/share/keyringer/edit b/share/keyringer/edit index dff42e6..8584c32 100755 --- a/share/keyringer/edit +++ b/share/keyringer/edit @@ -8,16 +8,10 @@ LIB="`dirname $0`/../../lib/keyringer/functions" source $LIB keyringer_set_env $* -# Aditional parameters -FILE="`keyringer_filename $2`" +# Get file +keyringer_get_file $2 -if [ -z "$FILE" ]; then - echo "Usage: keyringer `basename $0` " - exit 1 -elif [ ! -f "$KEYDIR/$FILE" ]; then - echo "File not found: $KEYDIR/$FILE" - exit 1 -elif [ -z "$EDITOR" ]; then +if [ -z "$EDITOR" ]; then echo "You have to set EDITOR env variable" exit 1 fi diff --git a/share/keyringer/recrypt b/share/keyringer/recrypt index 32a8a39..92afa99 100755 --- a/share/keyringer/recrypt +++ b/share/keyringer/recrypt @@ -8,15 +8,7 @@ LIB="`dirname $0`/../../lib/keyringer/functions" source $LIB keyringer_set_env $* -# Aditional parameters -FILE="`keyringer_filename $2`" - -if [ -z "$FILE" ]; then - echo "Usage: keyringer `basename $0` " - exit 1 -if [ ! -f "$KEYDIR/$FILE" ]; then - echo "File not found: $KEYDIR/$FILE" - exit 1 -fi +# Get file +keyringer_get_file $2 gpg --use-agent -d $KEYDIR/$FILE | gpg --use-agent --armor -e -s $(keyringer_recipients $RECIPIENTS) > $KEYDIR/$FILE -- cgit v1.2.3