Skip to content

fix: parse named file descriptor redirects - #13

Merged
aliou merged 1 commit into
docs/sh-ast-skillfrom
fix/named-fd-redirects
Aug 23, 2026
Merged

fix: parse named file descriptor redirects#13
aliou merged 1 commit into
docs/sh-ast-skillfrom
fix/named-fd-redirects

Conversation

@aliou

@aliou aliou commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

Port the {varname} redirect case from mvdan/sh (upstream commit 3fbbfb3, "{varname}> redirects work in Zsh too").

  • A braced valid name immediately followed by a redirect operator becomes the redirect's fd, e.g. foo {fd}<file and {fd}>>out foo.
  • Allowed in bash and zsh; rejected in posix and mksh with the upstream wording (`{varname}` redirects are a bash/zsh feature).
  • Anything that is not a valid name in braces still parses as a word ({1fd}>out, {fd-x}>out, {}>out), and { foo; } still parses as a Block.

Replaces #6, which was written on a remote branch.

Verification

  • Behavior cross-checked against real bash and zsh ({fd}>file redirects; {1a}>file is a literal word) and against upstream syntax/lexer.go:isLitRedir / syntax/parser.go:2049.
  • pnpm test (20 files, 270 tests), pnpm typecheck, pnpm check all pass.

@aliou
aliou force-pushed the fix/named-fd-redirects branch from b72b84f to 2d380b4 Compare July 30, 2026 06:33
@aliou
aliou changed the base branch from main to docs/sh-ast-skill July 30, 2026 06:34
@378-kaiabot
378-kaiabot Bot force-pushed the fix/named-fd-redirects branch from 2d380b4 to 0c2b57d Compare August 22, 2026 11:43
Port the {varname} redirect case from mvdan/sh (upstream 3fbbfb3). A
braced valid name immediately followed by a redirect operator becomes the
redirect's fd in bash and zsh; POSIX and mksh reject it, and anything
else still parses as a word.
@378-kaiabot
378-kaiabot Bot force-pushed the fix/named-fd-redirects branch from 0c2b57d to 1cc917d Compare August 22, 2026 12:00
@aliou
aliou merged commit 9b6c5e4 into main Aug 23, 2026
1 of 2 checks passed
@aliou
aliou deleted the fix/named-fd-redirects branch August 23, 2026 12:22
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.

1 participant