spm

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

commit 82e26fd97c3bf255bd14e44f6e8e084169ef9852
parent 203ea651e84e1c4ac9ab579bf26287eeb97c0a1d
Author: Klemens Nanni <kl3@posteo.org>
Date:   Fri,  5 Aug 2016 17:41:22 +0200

Fix parsing of 'list', change wording

Too many arguments were silently ignored in some cases, this fix should
prevent invalid invocations of `spm list' from being executed.

Messages and internal variable/function names have been changed for the
sake of clarity.

Diffstat:
Mspm.sh | 17++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/spm.sh b/spm.sh @@ -38,7 +38,7 @@ check() { [ -z "${entry}" ] && usage 'No such entry' [ "$(printf '%s' "${entry}" | wc -l)" -gt 0 ] \ - && usage "Too ambigious keyword. Try 'spm search'" + && usage "Ambigious keyword. Try 'spm search'" } gpg() { @@ -50,7 +50,7 @@ gpg() { readpw() { [ -t 0 ] && stty -echo && printf '%s' "${1}" IFS= read -r "${2}" - [ -z "${2}" ] && usage 'No password specified' + [ -z "${2}" ] && usage 'Empty password' } _search() { @@ -80,7 +80,7 @@ add() { list() { [ -d "${STORE_DIR}"/"${1:-}" ] || usage "No such group. See 'spm list'" - tree ${grps_only:+-d} --noreport -l --dirsfirst --sort=name -C \ + tree ${groups_only:+-d} --noreport -l --dirsfirst --sort=name -C \ -- "${STORE_DIR}"/"${1:-}" \ | view } @@ -106,16 +106,19 @@ show() { ## Parse input [ ${#} -eq 0 ] || [ ${#} -gt 3 ] \ -|| [ ${#} -eq 3 ] && [ "${1}" != list ] \ - && usage 'Invalid number of arguments' +|| [ ${#} -eq 3 -a "${1}" != list ] \ + && usage 'Wrong number of arguments' case "${1}" in add|del|search|show) - [ -z "${2}" ] && usage 'Name must not be empty' + [ -z "${2}" ] && usage 'Empty name' ${1} "${2}" ;; list) - [ "${2}" = -g ] && grps_only=1 && shift 1 + [ "${2}" = -g ] \ + && groups_only=1 && shift 1 \ + || [ ${#} -eq 3 ] \ + && usage 'Wrong number of arguments' list "${2}" ;; help)