bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: push cannot be redirected in 4.1.5


From: Greg Wooledge
Subject: Re: push cannot be redirected in 4.1.5
Date: Wed, 30 Apr 2014 16:48:57 -0400
User-agent: Mutt/1.4.2.3i

On Wed, Apr 30, 2014 at 04:39:28PM -0400, Chet Ramey wrote:
> On 4/30/14, 4:34 PM, Viktor Szépe wrote:
> > echo first $$ >&2 | bash -c 'echo second $$'
> > first 30551
> > second 28057
> > 
> > but 
> > 
> > eval 'echo first $$' >&2 | eval 'echo second $$'
> > first 30551
> > second 30551
> 
> $$ doesn't change in a subshell environment.  It changes in your first
> example because you're starting a new shell instance.

In bash 4.0 and higher, you can use the BASHPID variable to get the process
ID of a subshell.  $$ always gives the process ID of the main shell.

echo "main $$ $(echo "subshell $BASHPID")"



reply via email to

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