[PATCH] Add option --flat

Magnus Sandberg mem at fallback.netnod.se
Wed Jul 20 10:15:46 UTC 2022


Hi again,

I actually revert to my first version and oppose Kjetil's second 
comment. After some testing I found out that 'pass find $terms' matches 
pathnames, too.


A mix would be:
find ${PREFIX} -type f -name '*.gpg' | sed -E 's/\.gpg$//' | grep -i 
"${terms}" | sed -E "s|^${PREFIX}/||" | sort


Regards,
// mem



Den 2022-07-20 kl. 11:53, skrev Magnus Sandberg:
> Hi Andreas,
> 
> Thanks for adapting my idea, two comments;
> 
> - The 'sort' command was added as 'find' list found matches in "random 
> order" (inode order I guess). There are other places in /usr/bin/pass 
> where 'sort' is used. I prefer sort without LC_ALL=C to not force 
> case-sencitive sort.
> 
> - I think Kjetil has a good point of removing ${PREFIX} and '.gpg' 
> before the 'grep' to avoid "false positives" when a part of the path 
> (not the filename) would match ${terms}.
> 
> 
> An updated version would be:
> find ${PREFIX} -type f -name '*.gpg' | sed -E "s|^${PREFIX}/||" \
>      | sed -E 's/\.gpg$//' | grep -i "${terms}" | sort
> 
> 
> Regards,
> // mem
> 
> 
> 
> Den 2022-07-20 kl. 10:31, skrev Andreas Kölbl:
>> Hello,
>>
>> as I'm unsure, if compatibility is the aim of the project. The commit 
>> before on this line aimed to be compatible with tree 2.0 [1]. Since 
>> find and grep is already a dependency, sure I provide a version 
>> without tree.
>> I adapted the change, left sort out as this could be unintended use 
>> and appended suffix-removal after the first command.
>>
>> There are similar approaches with the aim to be POSIX-compatible [2]. 
>> Anyways, I'm unsure if they have the same wiede adoption and mass of 
>> compatible clients.
>>
>> But to allow different behavior here could be a compatible workaround. 
>> Any further suggestions are well appreciated.
>>
>> Kind Regards
>> Andreas
>>
>> [1] 
>> https://git.zx2c4.com/password-store/commit/?id=eea24967a002a2a81ae9b97a1fe972b5287f3a09 
>>
>> [2] https://github.com/dylanaraps/pash
>>
>> Am 19.07.22 um 12:06 schrieb Kjetil Torgrim Homme:
>>> On 19/07/2022 11:37, Magnus Sandberg wrote:
>>>> Hi,
>>>>
>>>> After a few minutes of manual testing at my shell prompt, I guess 
>>>> this one does the same;
>>>>
>>>> find ${PREFIX} -type f -name '*.gpg' | grep -i "${terms}" \
>>>>     | sed -E "s|^${PREFIX}/||" | sed -E 's/\.gpg$//' | sort
>>>>
>>>>
>>>>
>>>> Assuming that 'grep -i "${terms}"' would give the same result as
>>>> 'tree ... -P "${terms%|*}" ...'
>>>
>>> I would prefer a version which is not reliant on tree, too. 
>>> especially since it seems very fragile to try to remove the glyphs 
>>> used for the tree in the output.  (in fact, on my EL7 box, the 
>>> version of tree shipped with the distro is incompatible with pass, so 
>>> I run find(1) manually instead!)
>>>
>>> A small point - I think it is better to remove the prefix and .gpg 
>>> suffix before the grep to avoid unwanted matches (e.g., searching for 
>>> "home" :)
>>>


More information about the Password-Store mailing list