zsh-users
 help / color / mirror / code / Atom feed
* for loop body works, but not when called from for loop...
@ 2000-11-07 17:30 Jack McKinney
  2000-11-07 19:38 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Jack McKinney @ 2000-11-07 17:30 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1649 bytes --]

    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@lorentz.com
                                              1024D/D68F2C07 4096g/38AEF076

[-- Attachment #2: Type: application/pgp-signature, Size: 240 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: for loop body works, but not when called from for loop...
  2000-11-07 17:30 for loop body works, but not when called from for loop Jack McKinney
@ 2000-11-07 19:38 ` Bart Schaefer
  2000-11-07 19:44   ` Jack McKinney
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2000-11-07 19:38 UTC (permalink / raw)
  To: Jack McKinney, zsh-users

On Nov 7, 11:30am, Jack McKinney wrote:
> Subject: for loop body works, but not when called from for loop...
> 
> 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.  [...] the echo command echoes the correct filename
> (./test.pgp), but it just hangs there.

What version of zsh are we talking about?

Are you typing out that loop at a shell prompt, or is it in a script?  If
the latter, what else is in the script?  When you run the non-loop trial,
is everything the same except for the loop?

What happens if you run the loop version, and type control-D to send it an
EOF when it seems hung?

Something must be waiting for input.  I don't know exactly what, or whether
it might have something to do with file descriptor 3.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: for loop body works, but not when called from for loop...
  2000-11-07 19:38 ` Bart Schaefer
@ 2000-11-07 19:44   ` Jack McKinney
  0 siblings, 0 replies; 3+ messages in thread
From: Jack McKinney @ 2000-11-07 19:44 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 2139 bytes --]

Big Brother tells me that Bart Schaefer wrote:
> On Nov 7, 11:30am, Jack McKinney wrote:
> > Subject: for loop body works, but not when called from for loop...
> > 
> > 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.  [...] the echo command echoes the correct filename
> > (./test.pgp), but it just hangs there.
> 
> What version of zsh are we talking about?

    3.1.2, as compiled by debian 2.1.
> Are you typing out that loop at a shell prompt, or is it in a script?  If
> the latter, what else is in the script?  When you run the non-loop trial,
> is everything the same except for the loop?

     I am typing it at the prompt.  When it doesn't work, I type ctrl-C
to get back to the prompt, and set i to the value of the first file. Then,
I use the line editor to back up to the for loop and remove the loop and
run it.  It works fine, then.
     What I ended up doing was to put the body into a script, and then
ran the for loop to call the script.  This worked just fine.  I never
retyped anything, it was all copy and paste.

> What happens if you run the loop version, and type control-D to send it an
> EOF when it seems hung?

     Good question.  I just set this up again and tried it, and nothing
happens.  It does not appear to be waiting for stdin.

> Something must be waiting for input.  I don't know exactly what, or whether
> it might have something to do with file descriptor 3.

    It shouldn't, since it works fine outside the loop or inside a script
called by the loop.

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

[-- Attachment #2: Type: application/pgp-signature, Size: 240 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-11-07 19:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-11-07 17:30 for loop body works, but not when called from for loop Jack McKinney
2000-11-07 19:38 ` Bart Schaefer
2000-11-07 19:44   ` Jack McKinney

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).