[pass] 'pass find gpg' returns everything
nfb
notfreebeer at openmailbox.org
Wed Jul 29 12:57:44 CEST 2015
> Hi,
> this SHOULD be as simple as making one change in this line:
>
> tree -C -l --noreport -P "${terms%|*}" --prune --matchdirs
> - --ignore-case "$PREFIX" | tail -n +2 | sed -E
> 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g'
>
> from -P "${terms%|*}" to -P "${terms%|*}.gpg"
>
> assuming all file names end in gpg - directories would not be matched
> any more.
>
> But I'm saying "should", as it actually doesn't work.
>
> After some testing it looks to me that tree patterns seem to be buggy:
>
> tree [...] -P "*test*.gpg" [...]
>
> returns to me the same as
>
> tree [...] -P "*test*" [...]
>
> which are all files and directories containing "test", ignoring the
> extension.
>
> Disclaimer: I'm on a windows box and might have a strange version of
> tree. Could someone on a linux box test this?
Yes, running the tree command on the password-store directory, either
with "-P *gpg*" or "-P *gpg*.gpg" always returns every entry, and this
seems weird, let's see...
This is a little directory i just made for testing purposes:
» tree PASSDIR/
PASSDIR/
├── GPG
│ ├── firstkey.gpg
│ └── secondkey.gpg
├── NOTWHATIWANT
│ └── undesired.gpg
└── homeserver
└── gpgkey.gpg
3 directories, 4 files
Here are some commands run on it, using the same option used in the
pass script:
» tree -C -l --noreport -P '*gpg*' --prune --matchdirs --ignore-case
PASSDIR/
PASSDIR/
├── GPG
│ ├── firstkey.gpg
│ └── secondkey.gpg
├── NOTWHATIWANT
│ └── undesired.gpg
└── homeserver
└── gpgkey.gpg
» tree -C -l --noreport -P '*gpg*.gpg' --prune --matchdirs
--ignore-case PASSDIR/
PASSDIR/
├── GPG
│ ├── firstkey.gpg
│ └── secondkey.gpg
├── NOTWHATIWANT
│ └── undesired.gpg
└── homeserver
└── gpgkey.gpg
But...
» tree -C -l --noreport -P 'gpg*' --prune --matchdirs --ignore-case
PASSDIR/
PASSDIR/
├── GPG
│ ├── firstkey.gpg
│ └── secondkey.gpg
└── homeserver
└── gpgkey.gpg
which is good...
Now this seems to be like this because in the pass script, the line
preceding the tree command defines the 'terms' variable, which adds
an asterisk in front of the parameters:
local terms="*$(printf '%s*|*' "$@")"
Maybe the culprit is here, but i can't figure out how to test it right
now...
> So to fix this without meddling with tree, we would need some awk
> magic, and that could get a bit ugly.
> Anyone got a better solution?
What about not using .gpg extension at all within the password-store?
More information about the Password-Store
mailing list