Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

for loop body works, but not when called from for loop...



    You shouldn't need to know PGP or GPG for this.  The commands being
used here are just a filter: a pipeline copying stdin to stdout, but changing
it on the way.

    I have a bunch of PGP files that I want to convert to GPG.  Here is
the for loop I am using:

for i in $(find . -name \*.pgp | fgrep -v ring.pgp) ; do ; echo $i ; pgp -fd -z "My passphrase" < $i | gpg --passphrase-fd 3 --batch -c 3<<< "My passphrase" > ${i%pgp}gpg ; done

    When I run it, it echoes the first file it finds, and creates the .gpg
file (since it is stdout of one of the commands).  However, the file never
gets any data in it.  My first instinct is that I have the commands inside
the loop wrong.  So, I set i to this first file, and run just the body:

i=./test.pgp
pgp -fd -z "My passphrase" < $i | gpg --passphrase-fd 3 --batch -c 3<<< "My passphrase" > ${i%pgp}gpg

    Poof, the command executes in less than a second, and produces the
correct output file.  Since I actually run this command outside the loop
with $i in it, I know for certain that I have the body correct.  However,
when I run the loop version, the echo command echoes the correct filename
(./test.pgp), but it just hangs there.  The output file gets created by
the shell, but the pipeline never puts any data into it.

    Why would a for loop's body execute just fine on it own, but not when
called from the loop?

--
"Restore your inalienable human rights.       Jack McKinney
 Vote Libertarian.  http://www.lp.org         http://www.lorentz.com
 http://www.harrybrowne2000.org               jackmc@xxxxxxxxxxx
                                              1024D/D68F2C07 4096g/38AEF076

Attachment: pgpdQAXqG36ev.pgp
Description: PGP signature



Messages sorted by: Reverse Date, Date, Thread, Author