RE: BASH Scripting

Antonio Galea <[email protected]>
Newsgroups gmane.linux.redhat.release.enigma
Message-ID <Pine.LNX.4.44.0303191030280.2898-100000@beastieboy.uff.netwise.it>
On Wed, 19 Mar 2003, David Nithakorne wrote:

> Thanks very much for your response which has resolved my problem.
> However, it does leave me with a question. I have written the same
> script on HPUX and it worked fine there. Is this down to the difference
> in behaviour between BASH and KSH?
> 

A peek at ksh man page on my Linux box tells me that pipelines are
implemented using pipe(2):

       Commands can be chained together using the | token to form
       pipelines, in which the standard output  of  each  command
       but  the last is piped (see pipe(2)) to the standard input
       of the following command.

Whereas, the bash man page reports

       Each  command in a pipeline is executed as a separate pro­
       cess (i.e., in a subshell).

so they use fork(2) instead, and get a new environment (which is why your
vars are not propagated).

I guess this explains why it behaves like it does: didn't know that though,
so I'll ended up learning something new... thanks :-)

Ant9000


-- 
_____________________________________________________________________________
Dr. Antonio Galea       N e t   W i s e                 http://www.netwise.it
Sviluppo tecnico     Tecnologie per il Web    Tel 0461.421016 Fax 0461.426021
-----------------------------------------------------------------------------
"Most people's C programs should be indented six feet downward and
 covered with dirt."
-----------------------------------------------------------------------------
--
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.