From 0d9c02562ea5792fdf9691135a2b48f667a4c97d Mon Sep 17 00:00:00 2001 From: Brian Mattern Date: Mon, 20 May 2013 09:44:33 -0700 Subject: check if a passfile exists before checking for directory --- src/password-store.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/password-store.sh b/src/password-store.sh index d7b00b7..e080627 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -207,19 +207,8 @@ case "$command" in fi path="$1" - if [[ -d $PREFIX/$path ]]; then - if [[ -z $path ]]; then - echo "Password Store" - else - echo "${path%\/}" - fi - tree -l --noreport "$PREFIX/$path" | tail -n +2 | sed 's/\.gpg$//' - else - passfile="$PREFIX/$path.gpg" - if [[ ! -f $passfile ]]; then - echo "$path is not in the password store." - exit 1 - fi + passfile="$PREFIX/$path.gpg" + if [[ -f $passfile ]]; then if [[ $clip -eq 0 ]]; then exec gpg2 -d $GPG_OPTS "$passfile" else @@ -227,6 +216,16 @@ case "$command" in [[ -n $pass ]] || exit 1 clip "$pass" "$path" fi + elif [[ -d $PREFIX/$path ]]; then + if [[ -z $path ]]; then + echo "Password Store" + else + echo "${path%\/}" + fi + tree -l --noreport "$PREFIX/$path" | tail -n +2 | sed 's/\.gpg$//' + else + echo "$path is not in the password store." + exit 1 fi ;; insert) -- cgit v1.2.3