[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: piped functions cannot set variables
From: |
Andrew Robb |
Subject: |
Re: piped functions cannot set variables |
Date: |
Thu, 19 Dec 2002 14:19:25 +0000 |
Thanks for the reply Chet,
I am sorry, but E4 is rubbish!
The shell function is not running in a separate process, $$ gives the
same value in the shell function as the calling process. You'll have
to come up with a better excuse than that. My examples showed that it
is possible to 'hand craft' a pipeline to get bash to work properly
(like sh and ksh). I think bash has a real problem with the way it
implements pipes.
mkfifo /tmp/fifo
echo 1 2 3 > /tmp/fifo & read a b c < /tmp/fifo ; echo $a $b $c
1 2 3
This works as it should. Only bash has a problem with (echo 1 2 3 |
read a b c ; echo $a $b $c)
>>> Chet Ramey <chet@nike.ins.cwru.edu> 19/12/02 13:13:28 >>>
> under sh and ksh the following code echos 1
>
> fred() { A=1; } ; unset A ; echo hello | fred ; echo $A
>
> this does not work in bash.
Read the Bash FAQ, question E4.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Chet Ramey, ITS, CWRU chet@po.CWRU.Edu
http://cnswww.cns.cwru.edu/~chet/
________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a
proactive
anti-virus service working around the clock, around the globe,
visit:
http://www.star.net.uk
________________________________________________________________________
________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________