Hi

I have ended up with an appreciable amount of metadata along
with my passwords.  As such, I often find myself needing things
like case-insensitive searches, or a couple of lines of context
around the match, etc.

Would this little patch be acceptable?  It removes the
restriction of "exactly one argument" to grep so we can pass in
anything that grep itself will accept.

Thanks!
sitaram
>From fcaf0d62fd20686235754dd68a926f1ff0778e90 Mon Sep 17 00:00:00 2001
From: Sitaram Chamarty <sitar...@gmail.com>
Date: Sat, 18 Nov 2017 11:34:07 +0530
Subject: [PATCH] pass grep: allow grep options and arguments

Allow grep options and arguments.  Typical uses may be, for instance,
wanting to ignore case ('-i'), print a few lines of context around the
matched line, multiple patterns with '-e', etc.
---
 src/password-store.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/password-store.sh b/src/password-store.sh
index b86631d..1bb9a97 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -395,10 +395,10 @@ cmd_find() {
 }
 
 cmd_grep() {
-       [[ $# -ne 1 ]] && die "Usage: $PROGRAM $COMMAND search-string"
-       local search="$1" passfile grepresults
+       [[ $# -lt 1 ]] && die "Usage: $PROGRAM $COMMAND search-string"
+       local passfile grepresults
        while read -r -d "" passfile; do
-               grepresults="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | grep 
--color=always "$search")"
+               grepresults="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | grep 
--color=always "$@")"
                [[ $? -ne 0 ]] && continue
                passfile="${passfile%.gpg}"
                passfile="${passfile#$PREFIX/}"
-- 
2.13.6

_______________________________________________
Password-Store mailing list
Password-Store@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/password-store

Reply via email to