commit 51773096ae96015e98357ee1f6b04bcec5702fe1
parent 16a7ee379b8a2b982b36e226a24b020d0d4a6f7c
Author: Klemens Nanni <kl3@posteo.org>
Date: Fri, 3 Jun 2016 12:11:51 +0200
Move check for empty password from add() to readpw()
Diffstat:
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/spm.sh b/spm.sh
@@ -52,6 +52,7 @@ gpg() {
readpw() {
[ -t 0 ] && stty -echo && printf '%s' "${1}"
IFS= read -r "${2}"
+ [ -z "${2}" ] && die 'No password specified.'
}
## Commands
@@ -63,8 +64,6 @@ add() {
readpw "Password for '${1}': " password
[ -t 0 ] && printf '\n'
- [ -z "${password}" ] && die 'No password specified.'
-
mkdir -p "$(dirname "${STORE_DIR}"/"${1}".gpg)"
printf '%s\n' "${password}" \
| gpg --encrypt --output "${STORE_DIR}"/"${1}".gpg