Commit: b70e5ff4498e174c82fa89226fb535e171aec37b
Parent: cea14f036361ec725a870ebaf59d2f66821f2cdf
Author: Klemens Nanni
Date: Tue, 12 Jul 2016 12:48:43 +0200
Fix empty directories being created
Adding entries to the root of $PASSWORD_STORE_DIR caused empty
directories of the same name to be created, e.g.
$ spm add test
would add both the desired entry $PASSWORD_STORE_DIR/test.gpg as well as
an empty directory $PASSWORD_STORE_DIR/test/.
Thanks to Svyatoslav Mishyn <juef@openmailbox.org> for reporting this.
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/spm.sh b/spm.sh
@@ -64,7 +64,10 @@ add() {
readpw "Password for '${1}': " password
[ -t 0 ] && printf '\n'
- mkdir -p "${STORE_DIR}"/"${1%/*}"/
+ group=${1%/*}
+ [ "${group}" = "${1}" ] && group=
+
+ mkdir -p "${STORE_DIR}"/"${group}"/
printf '%s\n' "${password}" \
| gpg --encrypt --output "${STORE_DIR}"/"${1}".gpg
}