[TUHS] Use of "{}" in the Shell?
Sven Mascheck via TUHS
tuhs at tuhs.org
Wed Aug 5 07:11:22 AEST 2026
Actually correct, but $$ will be the same anyway, like in a better test
case
$ ( eval echo '$$' )
I'd put it this way:
- Purpose of a subshell is to avoid any changes in its environment to
kick back into the current shell
- ... while keeping non-exported variables available. They wouldn't
be inherited by a new sh command.
I wonder if keeping even $$ was an unintentional side effect. Or even
intentional:
The subshell shall see and behave very much like the original shell,
just not leave any traces in the environment after exiting?
Cheers,
Sven
Rich Salz via TUHS:
> Because shell variables are expanded before execution
>
> [...]
>
> On Tue, Aug 4, 2026, 1:23 PM David Barto<barto at kdbarto.org> wrote:
>
>> Then why does
>> echo me; echo $$
>> ( echo parens ; echo $$ ; )
>> { echo brace; echo $$ ; }
>>
>> Always echo the same pid?
More information about the TUHS
mailing list