small pixel drawing of a pufferfish pa

Add depends func
Jes Olson j3s@c3f.net
Tue, 27 Dec 2022 21:08:21 -0800
commit

67a48b741f44e1ed144f1bc23ff29a7c9d7f3d3f

parent

30f38c3a1e0f4826080cea176876693c3ada660b

1 files changed, 11 insertions(+), 5 deletions(-)

jump to
M papa

@@ -105,6 +105,13 @@ age-keygen -o ~/.age/key.txt

fi } +depends() { + for dep in $@; do + command -v "$dep" >/dev/null 2>&1 || + die "$dep not found, install per https://github.com/FiloSottile/age" + done +} + yn() { printf '%s [y/n]: ' "$1"

@@ -176,11 +183,7 @@

main() { : "${PA_DIR:=${XDG_DATA_HOME:=$HOME/.local/share}/pa}" - command -v age >/dev/null 2>&1 || - die "age not found, install per https://github.com/FiloSottile/age" - - command -v age-keygen >/dev/null 2>&1 || - die "age-keygen not found, install per https://github.com/FiloSottile/age" + depends age age-keygen mkdir -p "$PA_DIR" || die "Couldn't create password directory"

@@ -230,6 +233,9 @@

# Ensure that debug mode is never enabled to # prevent the password from leaking. set +x + +# +set -e # Ensure that globbing is globally disabled # to avoid insecurities with word-splitting.