View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001980 | 1003.1(2024)/Issue8 | Shell and Utilities | public | 2026-04-26 07:37 | 2026-04-26 07:45 |
| Reporter | stephane | Assigned To | |||
| Priority | normal | Severity | Objection | Type | Enhancement Request |
| Status | New | Resolution | Open | ||
| Name | Stephane Chazelas | ||||
| Organization | |||||
| User Reference | |||||
| Section | jobs utility | ||||
| Page Number | 3021, 3023 | ||||
| Line Number | 101088-101091, 101194 | ||||
| Interp Status | |||||
| Final Accepted Text | |||||
| Summary | 0001980: misleading reference to $(jobs -p) in jobs application usage | ||||
| Description | In the "APPLICATION USAGE" section, the jobs utility specification currently has: > Usage such as $(jobs -p) provides a way of referring to the > process group of the job in an implementation-independent way. However, $(...) instroduces a subshell environment and the "DESCRIPTION" section has: > If the current shell execution environment (see 2.13 Shell > Execution Environment) is not a subshell environment, the jobs > utility shall display the status of background jobs that were > created in the current shell execution environment; it may > also do so if the current shell execution environment is a > subshell environment. Meaning the expansion of $(jobs -p) is unspecified. What "so" means above in "it may also do so" should be clarified as it's unclear whether it may report jobs of the shell outside subshell environments, or jobs of the subshell environment or of the parent subshell environment or combinations thereof. In practice, there's a lot of variation between shells and in some shells, not all subshells are equal, with the ones created by command substitution treated differently from some other ones in some for instance. With bash: $ bash -c 'sleep 1 & (sleep 2 & (sleep 3 & jobs))' [1]+ Running sleep 3 & $ bash -c 'sleep 1 & (sleep 2 & printf "%s\n" "$(sleep 3 & jobs)")' [1]- Running sleep 2 & [2]+ Running sleep 3 & Similarly for subshells incurred by pipelines: $ bash -c 'sleep 1 & (jobs)' $ bash -c 'sleep 1 & jobs | cat' [1]+ Running sleep 1 & | ||||
| Desired Action | In the "APPLICATION USAGE" section, Remove the sentence: > Usage such as $(jobs -p) provides a way of referring to the > process group of the job in an implementation-independent way. Or change it to: > It provides a way of referring to the process group of a job > in an implementation-independent way. In the "DESCRIPTION" section, change: > it may also do so if the current shell execution environment > is a subshell environment. To: > If invoked in a subshell environment, whether it reports jobs of > the current (subshell) execution environment, of the parent > execution environment, or those outside any subshell > environment or combinations thereof and under what circumstance > is implementation-defined. Or leave the whole thing unspecified: > If invoked in a subshell environment, the behaviour is > unspecified. It's marked with the "User Portability Utilities" option anyway so shouldn't be used in POSIX scripts. | ||||
| Tags | No tags attached. | ||||
|
|
For context, it came up at this Q&A: https://unix.stackexchange.com/questions/672384/cant-grep-or-word-count-the-output-of-jobs-command-in-dash |