On Tue, Aug 18, 2015 at 11:32:42AM +0200, Lucas Hoffmann wrote: > On Tue, Aug 18, 2015 at 11:11:37AM +0200, Lucas Hoffmann wrote: > > On Tue, Aug 18, 2015 at 07:05:31AM +0000, Dahlberg, David wrote: > > > Would it be possible to replace --label/-H with cut/echo or sed? > > > > I think it is possible to implement the --label stuff with a pipeline. > > But I am currently thinking about a different approach: If GNU grep is > > available we can set some default options including color and label and > > if it is not available we can fall back to some default options that > > work with POSIX grep. This way we do not reimplement features of GNU > > grep in pass. And every user will get a "sane" default behaviour > > corresponding to the feature set of the available grep. > > > > I think this should be done with the platform mechanisms that pass > > already uses. But I have to understand them first before I can send the > > patch. I hope to do it soon though. > > Ok, the platform mechanisms is easier to understand than I thought. > Attached is a small patch (not yet to be commited). Please do send me > suggestions of options and GREP_TYPE that you might want to see in > different platform files. I will then prepare and send a full commit. > > Lucas
diff --git a/src/password-store.sh b/src/password-store.sh
index e6876b2..7959818 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -184,6 +184,7 @@ tmpdir() {
}
GETOPT="getopt"
SHRED="shred -f -z"
+GREP_TYPE=gnu
source "$(dirname "$0")/platform/$(uname | cut -d _ -f 1 | tr '[:upper:]' '[:lower:]').sh" 2>/dev/null # PLATFORM_FUNCTION_FILE
@@ -339,14 +340,19 @@ cmd_find() {
cmd_grep() {
[[ $# -eq 0 ]] && die "Usage: $PROGRAM $COMMAND [grep options] search-string"
- local passfile label
+ local passfile label options
while read -r -d "" passfile; do
label="${passfile%.gpg}"
label="${label#"$PREFIX"}"
label="${label#/}"
+ if [[ $GREP_TYPE = gnu ]]; then
+ options=( --color=auto --label="$label" -H )
+ else
+ options=( )
+ fi
# The user supplied options come after our defaults so that
# they can override the defaults.
- $GPG -d "${GPG_OPTS[@]}" "$passfile" | grep --color=auto --label="$label" -H "$@"
+ $GPG -d "${GPG_OPTS[@]}" "$passfile" | grep "${options[@]}" "$@"
done < <(find -L "$PREFIX" -iname '*.gpg' -print0)
}
signature.asc
Description: PGP signature
_______________________________________________ Password-Store mailing list [email protected] http://lists.zx2c4.com/mailman/listinfo/password-store
