bug-bash
[Top][All Lists]
Advanced

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

Re: 'wait' in command group in pipeline fails to recognize child process


From: Martin Jambon
Subject: Re: 'wait' in command group in pipeline fails to recognize child process
Date: Tue, 22 Jun 2021 18:54:18 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

On 6/22/21 6:11 PM, Lawrence Velázquez wrote:
On Tue, Jun 22, 2021, at 8:52 PM, Martin Jambon wrote:
It's better. However, the reader is still left wondering what "the
shell" is referring to in first sentence.

Subshells aside, I have a hard time believing that "the process ID
of the shell" confuses anybody in practice.  Even POSIX doesn't
overcomplicate this:

     $
         Expands to the decimal process ID of the invoked shell.  In
         a subshell (see Shell Execution Environment), '$' shall
         expand to the same value as that of the current shell.

(https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_05_02)

This language implies that a subshell is part of the shell but not a shell in itself. This is what I pointed out earlier but I received a conflicting answer.

This is confirmed by this definition from posix:

A subshell environment shall be created as a duplicate of the shell environment, except that signal traps that are not being ignored shall be set to the default action. Changes made to the subshell environment shall not affect the shell environment. Command substitution, commands that are grouped with parentheses, and asynchronous lists shall be executed in a subshell environment. Additionally, each command of a multi-command pipeline is in a subshell environment; as an extension, however, any or all commands in a pipeline may be executed in the current environment. All other commands shall be executed in the current shell environment.

(https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_12)

In the posix definition, a subshell
- is not necessarily implemented as a separate process
- belongs to a unique shell
- is not a shell

This makes the term "the shell" unambiguous to a reader who's aware of this - but it's obvious to me that "subshell" should be clarified in the context of '$$'.

A subset is a set, a subgroup is a group, a subtype is a type, a subtree is a tree, a subprocess is a process. However a submarine is not a marine, and a subshell is not a shell (sea stuff!).

Anyway, I left a suggestion to revise the documentation for '$$' in my previous email. That's the best I can produce at this time.

Martin



reply via email to

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