Piping to the 'read' command

Eric Blake ebb9@byu.net
Fri Oct 27 13:56:00 GMT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to cwmail@allmail.net on 10/27/2006 6:38 AM:
> Thanks Dave - I guess I should have explained in my original email that
> I'm converting a ksh script which currently runs successfully under
> HP-UX. If I run the following command under HP-UX ksh:
> 
>  echo "Test" | read VAR1 
> 
> VAR1 will hold the value "Test" in the parent environment. This doesn't
> happen under Cygwin pdksh, and I don't understand why.

Because POSIX doesn't guarantee it.  POSIX states that it is unspecified
whether the last command in a pipeline executes in the parent or in a
subshell.  In HP-UX's ksh, they have implemented it as the parent shell.
But on cygwin, both bash and pdksh have implemented it as the child shell.
 And assignments made by read in the child shell don't propagate back to
the parent.

By the way, none of this thread is cygwin-specific.

- --
Life is short - so eat dessert first!

Eric Blake             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFQf7984KuGfSFAYARAmlnAKDUu4j05wRdT7rT+2suwZ1r1eLYhgCgqH6R
1fftRbWxuf6Zkj76Hgv/HyM=
=pv4W
-----END PGP SIGNATURE-----

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list