Commit: 16a7ee379b8a2b982b36e226a24b020d0d4a6f7c Parent: 369bd733f9be580257128564226e2952c0215b39 Author: Klemens Nanni Date: Fri, 3 Jun 2016 03:55:44 +0200 Simplify readpw(), use &&/|| not if/else Diffstat:
M | spm.sh | | | 15 | ++++----------- |
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/spm.sh b/spm.sh @@ -44,21 +44,14 @@ _find() { } gpg() { - if [ -z "${PASSWORD_STORE_KEY}" ]; then - gpg2 ${GPG_OPTS} --default-recipient-self "${@}" - else - gpg2 ${GPG_OPTS} --recipient "${PASSWORD_STORE_KEY}" "${@}" - fi + [ -z "${PASSWORD_STORE_KEY}" ] \ + && gpg2 ${GPG_OPTS} --default-recipient-self "${@}" \ + || gpg2 ${GPG_OPTS} --recipient "${PASSWORD_STORE_KEY}" "${@}" } readpw() { - if [ -t 0 ]; then - printf '%s' "${1}" - stty -echo - fi - + [ -t 0 ] && stty -echo && printf '%s' "${1}" IFS= read -r "${2}" - [ -t 0 ] && stty echo } ## Commands