diff options
-rw-r--r-- | man/pass.1 | 7 | ||||
-rwxr-xr-x | src/password-store.sh | 4 | ||||
-rwxr-xr-x | tests/t0400-grep.sh | 12 |
3 files changed, 18 insertions, 5 deletions
@@ -81,12 +81,13 @@ by using the .BR tree (1) program. This command is alternatively named \fBlist\fP. .TP -\fBgrep\fP \fIsearch-string\fP +\fBgrep\fP [\fIGREPOPTIONS\fP] \fIsearch-string\fP Searches inside each decrypted password file for \fIsearch-string\fP, and displays line containing matched string along with filename. Uses .BR grep (1) -for matching. Make use of the \fIGREP_OPTIONS\fP environment variable to set particular -options. +for matching. \fIGREPOPTIONS\fP are passed to +.BR grep (1) +as-is. (Note: the \fIGREP_OPTIONS\fP environment variable functions as well.) .TP \fBfind\fP \fIpass-names\fP... List names of passwords inside the tree that match \fIpass-names\fP by using the diff --git a/src/password-store.sh b/src/password-store.sh index b852d06..0c9b35d 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -266,7 +266,7 @@ cmd_usage() { $PROGRAM [show] [--clip[=line-number],-c[line-number]] pass-name Show existing password and optionally put it on the clipboard. If put on the clipboard, it will be cleared in $CLIP_TIME seconds. - $PROGRAM grep search-string + $PROGRAM grep [GREPOPTIONS] search-string Search for password files containing search-string when decrypted. $PROGRAM insert [--echo,-e | --multiline,-m] [--force,-f] pass-name Insert new password. Optionally, echo the password back to the console @@ -395,7 +395,7 @@ cmd_find() { } cmd_grep() { - [[ $# -lt 1 ]] && die "Usage: $PROGRAM $COMMAND search-string" + [[ $# -lt 1 ]] && die "Usage: $PROGRAM $COMMAND [GREPOPTIONS] search-string" local passfile grepresults while read -r -d "" passfile; do grepresults="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | grep --color=always "$@")" diff --git a/tests/t0400-grep.sh b/tests/t0400-grep.sh index 206377f..b244cf4 100755 --- a/tests/t0400-grep.sh +++ b/tests/t0400-grep.sh @@ -18,4 +18,16 @@ test_expect_success 'Make sure grep prints normal lines' ' grep -q "They are" <<<"$results" ' +test_expect_success 'Test passing the "-i" option to grep' ' + "$PASS" init $KEY1 && + "$PASS" insert -e blah1 <<<"I wonder..." && + "$PASS" insert -e blah2 <<<"Will it ignore" && + "$PASS" insert -e blah3 <<<"case when searching?" && + "$PASS" insert -e folder/blah4 <<<"Yes, it does. Wonderful!" && + results="$("$PASS" grep -i wonder)" && + [[ $(wc -l <<<"$results") -eq 4 ]] && + grep -q blah1 <<<"$results" && + grep -q blah4 <<<"$results" +' + test_done |