bug-bash
[Top][All Lists]
Advanced

[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: Fri, 20 Dec 2002 15:35:06 +0000

Thanks Paul,
I wasn't aware that $$ is not maintained by subprocess functions.
This makes quite a lot of sense for lock files containing a pid.

But I think it is a major weakness not to be able to duplicate the
piping action of sh and ksh.
So I request that bash be changed to work more like sh and ksh in
this case,
i.e. the rightmost builtin/function in a pipe list is run in the
current process.

Therefore,
echo hi | read A
will set A=hi in the current shell (like sh and ksh)

FYI ksh seems to fork all commands to the left of a pipe.

>>> Paul Jarc <prj@po.cwru.edu> 19/12/02 17:07:25 >>>
"Andrew Robb" <arobb@mva.co.uk> wrote:
> The shell function is not running in a separate process,

It is.  You can observe this with a system call trace.

> $$ gives the same value in the shell function as the calling
> process.

$$ also gives the same value inside an explicit subshell like
"(command)"; would you claim that no extra process is created then?
$$ doesn't mean what you think it means in these situations.  It is
initialized with getpid() when the shell first starts, and is not
reset for subprocesses.

You might make a feature request, saying that bash *shouldn't* fork
a
subprocess when the pipeline element is a shell function.  But that
is
indeed what it does currently.


paul

________________________________________________________________________
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
________________________________________________________________________



reply via email to

[Prev in Thread] Current Thread [Next in Thread]