Commit: a94f0f3c3d4cc69601f6dda7760bd0c6c6980315
Parent: b34b62ba263682b69b410b7de5cb587059fab91d
Author: Klemens Nanni
Date: Mon, 30 May 2016 12:37:39 +0200
Work around nested quotes
spm/fb0ee58 doesn't work as supposed to, the easiest way to to this is
by using a helper function for now (still being POSIX compliant).
See https://github.com/nmeum/tpm/pull/6 for more information.
Diffstat:
M | spm.sh | | | 22 | ++++++++++++---------- |
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/spm.sh b/spm.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (C) 2013-2015 Sören Tempel
+# Copyright (C) 2013-2016 Sören Tempel
# Copyright (C) 2016 Klemens Nanni <kl3@posteo.org>
#
# This program is free software: you can redistribute it and/or modify
@@ -22,12 +22,6 @@ umask 077
GPG_OPTS='--quiet --yes --batch'
STORE_DIR="${PASSWORD_STORE_DIR:-${HOME}/.spm}"
-if [ -z "${PASSWORD_STORE_KEY}" ]; then
- GPG_OPTS="${GPG_OPTS} --default-recipient-self"
-else
- GPG_OPTS="${GPG_OPTS} --recipient '${PASSWORD_STORE_KEY}'"
-fi
-
## Helper
die() {
@@ -35,6 +29,15 @@ die() {
exit 1
}
+gpg() {
+ echo "_${PASSWORD_STORE_KEY}_"
+ if [ -z "${PASSWORD_STORE_KEY}" ]; then
+ gpg2 ${GPG_OPTS} --default-recipient-self "${@}"
+ else
+ gpg2 ${GPG_OPTS} --recipient "${PASSWORD_STORE_KEY}" "${@}"
+ fi
+}
+
readpw() {
if [ -t 0 ]; then
printf '%s' "${1}"
@@ -58,8 +61,7 @@ add() {
mkdir -p "$(dirname "${STORE_DIR}"/"${1}".gpg)"
printf '%s\n' "${password}" \
- | gpg2 ${GPG_OPTS} --encrypt \
- --output "${STORE_DIR}"/"${1}".gpg
+ | gpg --encrypt --output "${STORE_DIR}"/"${1}".gpg
}
list() {
@@ -96,7 +98,7 @@ show() {
&& die 'Too ambigious keyword.'
fi
- gpg2 ${GPG_OPTS} --decrypt "${entry}"
+ gpg --decrypt "${entry}"
}
## Parse input