commit f74ef5c3ec516d48f49d8e6dcb4ee7b04c08edba
parent 25089a9140eab8b3f87c6b608d1d01aeeca2db93
Author: Klemens Nanni <kl3@posteo.org>
Date: Wed, 2 Nov 2016 02:14:11 +0100
Use basic regular expressions, simplify code
Besides getting the benefits of BREs over shell globbing, this also
makes spm(1) work on OpenBSD as their find(1) does not support the
-printf option.
Diffstat:
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/spm.1 b/spm.1
@@ -1,4 +1,4 @@
-.TH spm 1 2016-09-16 spm-1.4.7 "Commands Manual"
+.TH spm 1 2016-11-02 spm-1.4.7 "Commands Manual"
.SH NAME
spm \- simple password manager
.SH SYNOPSIS
@@ -25,10 +25,12 @@ entries inside the specified group as well as all its subgroups. If no name is
given, all entries will be listed. Passing \fI\-g\fR as first parameter causes
it to list groups only.
.PP
-Globbing is allowed for the \fIdel\fR, \fIsearch\fR and \fIshow\fR commands to
-avoid typing long entry names. In case multiple entries match, spm exits
-without removing or showing any password but printing a warning instead.
-Searching will show all matching paths.
+To avoid typing long entry names and make searching more effective, input for
+the \fIdel\fR, \fIsearch\fR and \fIshow\fR commands is treated as basic
+regular expression. In case multiple entries match, spm exits without removing
+or showing any password but printing a warning instead. Searching will show all
+matching paths.
+
.PP
\&\fIhelp\fR prints short usage information and refers to this manual page.
.SH NOTES
@@ -77,7 +79,7 @@ Write the entry's password that matches the given pattern to standard
output:
.PP
.Vb 1
-\& $ spm show em/r*t
+\& $ spm show ^.+em/r[a-z]*t
.Ve
.PP
Copy your 'system/root' password to the clipboard using \fIxclip\fR\|(1):
diff --git a/spm.sh b/spm.sh
@@ -54,8 +54,8 @@ readpw() {
}
_find() {
- find "${STORE_DIR}"/ \( -type f -o -type l \) -iwholename "*${1}*".gpg \
- -printf "${2:-%p\n}"
+ find "${STORE_DIR}"/ \( -type f -o -type l \) -name \*.gpg \
+ | grep -G -i "${1}"
}
view() {
@@ -81,7 +81,7 @@ add() {
list() {
[ -d "${STORE_DIR}"/"${1:-}" ] || usage "No such group. See 'spm list'"
- tree ${groups_only:+-d} --noreport -l --dirsfirst --sort=name -C \
+ tree ${groups_only:+-d} -F \
-- "${STORE_DIR}"/"${1:-}" \
| view
}