spm

Personal fork of spm (simple password manager)
git clone git@getsh.org:spm.git
Log | Files | Refs | README | LICENSE

commit 83db637a1d59db7a9a453d74c532719f3912bdfa
parent 65de0301c9f457c0a4a67c7a534fe67e79561c16
Author: Klemens Nanni <kl3@posteo.org>
Date:   Wed,  2 Mar 2016 04:09:38 +0100

Match entries on patterns as well

This allows 'tpm show sys*r' or 'tpm show m/f' instead of
'tpm show system/foo/bar' to match the requested entry if and only if it
is the only entry matching the pattern.

Diffstat:
Mtpm | 13+++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tpm b/tpm @@ -89,9 +89,18 @@ remove() { show() { [ -z "${1}" ] && abort "USAGE: tpm show ENTRY" - [ -e "${STORE_DIR}"/"${1}".gpg ] || abort "The requested entry doesn't exist." + entry="${STORE_DIR}"/"${1}".gpg + + if [ ! -e "${entry}" ]; then + entry=$(find "${STORE_DIR}" -type f -iwholename "*${1}*".gpg) + + [ -z "${entry}" ] && abort "The requested entry doesn't exist." + + [ "$(printf '%s' "${entry}" | wc -l)" -gt 0 ] \ + && abort "The given keyword is too ambigious." + fi - gpg2 ${GPG_OPTS} --decrypt "${STORE_DIR}"/"${1}".gpg + gpg2 ${GPG_OPTS} --decrypt "${entry}" } ### Parse input ###