[PATCH] add new dump command
David A.
listmail at cox.net
Sat Feb 4 19:09:16 CET 2017
On Sat, 4 Feb 2017 12:15:12 -0500, Dusty Mabe <dusty at dustymabe.com>
wrote:
>This dump command will decrypt all passwords and print them.
...
>+cmd_dump() {
>+ pushd $PREFIX > /dev/null
>+ find ./* -name *gpg | while read file; do
>+ echo "[$file]" | sed 's/\.\///' | sed 's/\.gpg//'
>+ $GPG ${GPG_OPTS[@]} -d $file
>+ echo -en "\n\n"
>+ done
>+ popd > /dev/null
>+}
I think this is very easily accomplished with a simple external script
today. However, I'll give you some feedback on your patch because I
see several problems with it that would prevent acceptance.
First, you should declare your variables as local. So add 'local
file' to the top. As a matter of consistency it appears the pass
script prefers to use 'passfile' instead of 'file'.
I have two problems and a suggestion for your find command:
I suggest 'find *' instead of 'find ./*' so you can eliminate the
first sed.
You should limit the find with '-type f'. There could be directories
that end in 'gpg'.
You need to quote the name filter. If there are any entries in the
root of the password store then your find will fail. So change *gpg
(unquoted) to '*gpg' (with quotes) and I would add the dot for
accuracy so '*.gpg' is the way to go.
Since pass is written in bash you can eliminate both sed statements.
It's faster to do string substitution in the shell than to spawn two
processes. Since we've already eliminated the first sed by changing
find there's only one substitution to make so we can do it right on
the echo command. Change:
echo "[$file]" | sed ...
to:
echo "[${file%.gpg}]"
On the gpg command you need to add double quotes around ${GPG_OPTS[@]}
and around $file.
As a matter of style, why use this:
echo -en "\n\n"
rather than this:
echo -e "\n"
?
More information about the Password-Store
mailing list