grep -i?

Sitaram Chamarty sitaramc at gmail.com
Thu May 24 13:17:18 CEST 2018


On Thu, May 24, 2018 at 01:04:26PM +0200, Jason A. Donenfeld wrote:
> Hey Sitaram,
> 
> Indeed passing grep arguments straight through to grep seems reasonable.
> I'll take a look at this.

Thanks.

Would this patch help?

regards
sitaram

> 
> Jason
> 
> On Thu, May 24, 2018, 12:47 Sitaram Chamarty <sitaramc at gmail.com> wrote:
> 
> > Hi
> >
> > Is there any possibility of "pass grep" gaining the ability to specify
> > options?
> >
> > grep puts out a deprecation warning when GREP_OPTIONS is used, and "man
> > grep" says it will be "removed in a future release of grep".
> >
> > thanks
> >
> > --
> > sitaram
> > _______________________________________________
> > Password-Store mailing list
> > Password-Store at lists.zx2c4.com
> > https://lists.zx2c4.com/mailman/listinfo/password-store
> >
-------------- next part --------------
>From 91447136dba874f83e43b1d1aa5cc961b878441c Mon Sep 17 00:00:00 2001
From: Sitaram Chamarty <sitaramc at gmail.com>
Date: Thu, 24 May 2018 16:46:01 +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.

(background: grep is deprecating GREP_OPTIONS, so eventually that will
stop working).
---
 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 eac5404..19b3124 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.14.3



More information about the Password-Store mailing list