URL:
<https://savannah.gnu.org/support/?111047>
Summary: Value of BASHPID changes when inside a here-document
Group: The GNU Bourne-Again SHell
Submitter: rmwaite
Submitted: Thu 04 Apr 2024 09:57:30 PM UTC
Category: None
Priority: 5 - Normal
Severity: 3 - Normal
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Operating System: Mac OS
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Thu 04 Apr 2024 09:57:30 PM UTC By: Richard Waite <rmwaite>
I noticed that BASHPID expands to a different PID value compared to the value
outside of it.
$ echo $BASHPID
77362
$ cat << EOF
> $BASHPID
> EOF
77507
Does variable expansion for here-documents occur in a subshell? Checking the
value of BASH_SUBSHELL seems to indicate no:
$ cat << EOF
> $BASH_SUBSHELL
> EOF
0
However, I did find this note about BASHPID in bash(1):
> This differs from +nomarkup+$$-nomarkup- under certain circumstances, such
as subshells that do not require bash to be re-initialized.
Are here-documents one of these circumstances? I suspect this is due to the
way here-documents are handled internally, but any insight into this behavior
would be greatly appreciated.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/support/?111047>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/