Repository navigation
fix: omit coproc name from jobs display for simple bodies (#1645) - #1699
Merged
Merged
Conversation
GNU print_cmd.c `cm_coproc` (5.3.20) prints the coproc name ONLY
when the body is not a simple command: `coproc sleep 5` displays as
`coproc sleep 5 &`, while `coproc { sleep 5; }` / `coproc C1
{ sleep 5; }` display with their names. Rubash's
coproc_command_source_text always printed the name (defaulting an
unnamed coproc to COPROC), so `jobs` showed `coproc COPROC sleep 5
&`. The old comment here claimed GNU always prints the name; that
matches bash 5.2's print code, not 5.3.20's.
The fix prints the name only when body_kind != SimpleCommand.
There is no `COPROC WORD simple_command` production, so a simple
body never carries a real name: `coproc FOO sleep 5` is an unnamed
coproc of [FOO, sleep, 5] and now displays as `coproc FOO sleep 5
&` (was `coproc COPROC FOO sleep 5 &`). Compound bodies are
unchanged. The rendering feeds jobs, jobs -l, and every other
command display, matching GNU's single print_command; round-trip
re-parse is unaffected (simple bodies never had a name to lose).
Tests: new tests/issue1645_jobs_coproc_name.rs (7 cases: simple,
jobs -l, named/unnamed group, FOO-before-simple-body,
FOO-before-group, disown control).
Known adjacent gap, NOT fixed here: a subshell coproc body still
renders as `{ sleep 5; }` instead of GNU's `( sleep 5 )` — the
compound-body shape rendering in the same function, separate from
the name question.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1645.
Bug
After a simple-command coproc,
jobsprinted the auto-generated name (coproc COPROC sleep 5 &); GNU printscoproc sleep 5 &. Cosmetic only; job control itself agreed.Root cause (GNU source)
Vendored
third_party/bash/print_cmd.c,cm_coproccase (5.3.20):The name is printed ONLY when the body is not a simple command. Rubash's
coproc_command_source_textalways printed it (defaulting an unnamed coproc toCOPROC) — and its comment even claimed GNU always prints the name. That matches bash 5.2's print code, not 5.3.20's, so the local system bash (5.2) is not the oracle here; the vendored 5.3.20 source and the issue's 5.3.20 measurements are.Change
src/executor/command_text.rs: print the name only whenbody_kind != SimpleCommand. Consequences, all verified against the 5.3.20 rule:coproc sleep 5→coproc sleep 5 &(wascoproc COPROC sleep 5 &)coproc { sleep 5; }→coproc COPROC { sleep 5; } &(unchanged, group form already agreed)coproc C1 { sleep 5; }→coproc C1 { sleep 5; } &(unchanged)coproc FOO sleep 5→coproc FOO sleep 5 &(wascoproc COPROC FOO sleep 5 &; there is noCOPROC WORD simple_commandproduction, so FOO is argv[0], not a name)coproc FOO { sleep 5; }→coproc FOO { sleep 5; } &(unchanged)The rendering feeds
jobs,jobs -l, and every other command display, matching GNU's singleprint_command. Round-trip re-parse is unaffected: simple bodies never carried a real name to lose, and compound bodies keep theirs.Verification
tests/issue1645_jobs_coproc_name.rs: 7 cases (simple,jobs -l, named/unnamed group, FOO-before-simple-body, FOO-before-group, disown control), all passing.parser_coproc_tests31,issue1528,issue352,issue387,issue1370) and jobs family (issue1494,issue549,issue550) all green.issue1653_coproc_timesuite (from the sibling fix: coproc time is a plain word, not the time keyword (#1653) #1698 branch, borrowed temporarily, not committed here) shows the identical failure set with and without this change (8 failed / 2 passed — all 8 are the missing [bug] coproc time CMD | CAT sets COPROC in parent; GNU leaves it unset (pipeline-of-coproc parse) #1653 parser fix on this branch, not this change).Known adjacent gap, not fixed here
A subshell coproc body still renders as
{ sleep 5; }instead of GNU's( sleep 5 )— the compound-body shape rendering in the same function, separate from the name question.