all repos — pw @ 0a5b7244b36afce7b95e77d1ce8acda600513a9a

minimal password store

Add checkf helper function

Checks if file exists, dies otherwise

Signed-off-by: Anirudh Oppiliappan <x@icyphox.sh>
Anirudh Oppiliappan x@icyphox.sh
Sun, 17 Nov 2019 15:10:27 +0530
commit

0a5b7244b36afce7b95e77d1ce8acda600513a9a

parent

ec848fac2e389b04c481c53a994ac104ccb4aa03

1 files changed, 10 insertions(+), 0 deletions(-)

jump to
M pwpw

@@ -34,6 +34,7 @@ fi

} del() { + checkf "$PW_DIR/$1.gpg" read -rn 1 -p "pw: are you sure you want to delete $1? [y/n]: " printf "\n" [[ "$REPLY" == [yY] ]] && {

@@ -43,10 +44,14 @@ }

} show() { + checkf "$PW_DIR/$1.gpg" gpg2 --decrypt --quiet --use-agent "$PW_DIR/$1.gpg" } +# TODO: rework having to checkf twice + copy() { + checkf "$PW_DIR/$1.gpg" show "$1" | xclip -selection clipboard echo "pw: copied $1 to clipboard" }

@@ -72,6 +77,11 @@ "

echo "$usage" exit 1 +} + +checkf() { + [[ ! -f "$1" ]] && + die "$1 does not exist" } die() {