Skip to content

fix: parse process substitution targets in combined redirects - #22

Merged
webpro merged 2 commits into
webpro-nl:mainfrom
everton-dgn:fix/parse-combined-process-redirections
Nov 7, 2026
Merged

webpro merged 2 commits into
webpro-nl:mainfrom
everton-dgn:fix/parse-combined-process-redirections

Conversation

@everton-dgn

Copy link
Copy Markdown
Contributor

cmd &> >(tee log) currently reports a missing redirect target and treats the process substitution as another argument. The same happens with &>> and <(...) targets.

Use the existing balanced-target handling for these combined redirects. The tests cover both directions, adjacent tokens, incomplete targets, nested diagnostics and printing. Concatenating a process substitution with more text keeps the existing limitation discussed in #19.

All 2,074 tests, type checks, build and formatting passed. Lint passed with the same four existing warnings. Bash 5.1 accepted the 19 valid inputs and their printed output, and the runtime smoke passed on Node 14.

`cmd &> >(tee log)` currently reports a missing redirect target and treats the process substitution as another argument. The same happens with `&>>` and `<(...)` targets.

Use the existing balanced-target handling for these combined redirects. The tests cover both directions, adjacent tokens, incomplete targets, nested diagnostics and printing. Concatenating a process substitution with more text keeps the existing limitation discussed in webpro-nl#19.

All 2,074 tests, type checks, build and formatting passed. Lint passed with the same four existing warnings. Bash 5.1 accepted the 19 valid inputs and their printed output, and the runtime smoke passed on Node 14.

@webpro webpro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Éverton! This fixes a real gap: Bash 5.3 runs cmd &> >(tee log), while main reports a missing redirect target and turns >(tee log) into an argument, and &> >(tee -a log) is a common idiom. On your branch the structured target, positions, lazy errors inside the substitution and printing all check out, &>>>(tee log) and &><(cat input) parse, and &>>(cat) stays an error as in Bash. The branch merges cleanly with main, the full suite passes on the merged tree, and throughput on the README fixtures is unchanged within run-to-run spread, as expected for a branch that only runs on &> tokens.

One change before merging, inline below: the new block is a copy of the process-substitution target handling that the shared redirect tail of tryReadOperator already has, even though the description says the existing balanced-target handling is reused. Once the two share one implementation this is good to go.

Comment thread src/lexer.ts Resolved
@pkg-pr-new

pkg-pr-new Bot commented Nov 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/unbash@22

commit: 7b4a038

@webpro webpro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick turnaround. readRedirectTarget is exactly the shape I had in mind, and the move is verbatim: outside the intended inputs, every fixture in the repository parses to an identical AST and prints identically on this branch and on main, and the full suite passes on the branch merged with current main. Since the tail is now a call on every redirect token, I benchmarked the merge against main on the README fixtures in isolated runs: throughput is unchanged within run-to-run spread.

@webpro
webpro merged commit c073596 into webpro-nl:main Nov 7, 2026
3 checks passed
@webpro

webpro commented Nov 7, 2026

Copy link
Copy Markdown
Member

🚀 This pull request is included in v6.0.4. See Release 6.0.4 for release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants