bug-bash
[Top][All Lists]
Advanced

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

Re: [sr #111047] Value of BASHPID changes when inside a here-document


From: Lawrence Velázquez
Subject: Re: [sr #111047] Value of BASHPID changes when inside a here-document
Date: Thu, 4 Apr 2024 21:05:33 -0400

Reproducing my comment [1] for the list:


> On Apr 4, 2024, at 5:57 PM, Richard Waite <INVALID.NOREPLY@gnu.org> wrote:
> 
> Does variable expansion for here-documents occur in a subshell?

Sometimes.  When a command requires forking (roughly speaking), its
redirections (not just here-documents) are processed after the fork
as an optimization.  For more details, including workarounds, see:

  - https://mywiki.wooledge.org/BashPitfalls#pf64
  - https://www.vidarholen.net/contents/blog/?p=865
  - https://lists.gnu.org/archive/html/help-bash/2024-02/msg00022.html


> Checking the value of BASH_SUBSHELL seems to indicate no:

This is not a context in which BASH_SUBSHELL is incremented.  As
per Chet [2]:

> From: Chet Ramey <chet.ramey@case.edu>
> Subject: Re: BASH_SUBSHELL is not incrementing when part of a pipeline
> Date: August 8, 2023 at 10:06:48 AM EDT
> To: Kamil Cukrowski Priv <kamilcukrowski@gmail.com>, bug-bash@gnu.org
> Cc: chet.ramey@case.edu
> Reply-To: chet.ramey@case.edu
> 
> On 8/7/23 9:56 AM, Kamil Cukrowski Priv wrote:
>> Hi, when BASH_SUBSHELL is part of a pipeline with just a simple command it 
>> does not increment. Consider the following:
> 
> Yes. BASH_SUBSHELL increments for asynchronous commands (&), commands
> explicitly in subshells, compound commands in pipelines, coprocesses,
> process substitution, and command substitution.


[1]: https://savannah.gnu.org/support/?111047#comment1
[2]: https://lists.gnu.org/archive/html/bug-bash/2023-08/msg00017.html

-- 
vq


reply via email to

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