add support for both gpg and gpg2

This commit is contained in:
Dylan Araps 2019-02-25 01:08:50 +02:00
parent 5dfdaf0666
commit 9767b9d4f8
1 changed files with 3 additions and 3 deletions

6
pash
View File

@ -23,7 +23,7 @@ pw_add() {
mkdir -p "${1%/*}" || die "Couldn't create category '${1%/*}'." mkdir -p "${1%/*}" || die "Couldn't create category '${1%/*}'."
} }
gpg2 -co "$1.gpg" <<< "$password" "${gpg[0]}" -co "$1.gpg" <<< "$password"
} }
pw_del() { pw_del() {
@ -34,7 +34,7 @@ pw_del() {
} }
pw_show() { pw_show() {
read -r password < <(gpg2 -dq "$1.gpg" || read -r password < <("${gpg[0]}" -dq "$1.gpg" ||
die "Failed to decrypt '$1'." die "Failed to decrypt '$1'."
) )
} }
@ -125,7 +125,7 @@ get_args() {
main() { main() {
get_args "$@" get_args "$@"
hash gpg2 2>/dev/null || mapfile -t gpg < <(type -p gdg gpg2) && [[ ! -x ${gpg[0]} ]] &&
die "GPG not found." die "GPG not found."
[[ -r /dev/urandom ]] || [[ -r /dev/urandom ]] ||