commit dda2ecce34de808d22b4b0f388bd1cb640158a29
parent fab65bda88ea979dbbc49f3d856a1d14ee4f1296
Author: Sitaram Chamarty <sitaramc@gmail.com>
Date: Thu, 24 May 2018 16:46:01 +0530
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).
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git 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/}"