commit de26bd28d4862d7776a192a746c1da13958cfb2b
parent 5aa72ae44f05096bc60707ace5cf09ca8a64a51a
Author: Klemens Nanni <kl3@posteo.org>
Date: Fri, 17 Jun 2016 01:35:42 +0200
Do not use mkdir(1) in 'list', use shell substitutions
Diffstat:
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/spm.sh b/spm.sh
@@ -49,7 +49,7 @@ readpw() {
}
_search() {
- find "${STORE_DIR}" \( -type f -o -type l \) \
+ find "${STORE_DIR}"/ \( -type f -o -type l \) \
-iwholename "*${1}*".gpg
}
@@ -57,7 +57,6 @@ view() {
sed s/.gpg//g | less -E -i -K -R -X
}
-
## Commands
add() {
@@ -66,18 +65,16 @@ add() {
readpw "Password for '${1}': " password
[ -t 0 ] && printf '\n'
- mkdir -p "$(dirname "${STORE_DIR}"/"${1}".gpg)"
+ mkdir -p "${STORE_DIR}"/"${1%/*}"/
printf '%s\n' "${password}" \
| gpg --encrypt --output "${STORE_DIR}"/"${1}".gpg
}
list() {
- [ -d "${STORE_DIR}" ] || mkdir -p "${STORE_DIR}"
-
- [ -d "${STORE_DIR}/${1}" ] || die "No such group. See 'spm list'"
+ [ -d "${STORE_DIR}"/"${1:-}" ] || die "No such group. See 'spm list'"
tree ${grps_only:+-d} --noreport -l --dirsfirst --sort=name -C \
- -- "${STORE_DIR}/${1}" \
+ -- "${STORE_DIR}"/"${1:-}" \
| view
}