backticks: implement brace expansion in command literals#61559
Draft
StefanKarpinski wants to merge 3 commits intomasterfrom
Draft
backticks: implement brace expansion in command literals#61559StefanKarpinski wants to merge 3 commits intomasterfrom
StefanKarpinski wants to merge 3 commits intomasterfrom
Conversation
Implement `|`, `<`, `>`, `>>`, `2>`, `2>>`, `1>`, and `0<` operators in backtick command literals. These lower to `pipeline()` calls at parse time, so `` `ls | sort > out.txt` `` works as expected. Fd-prefixed redirects (`2>`, `1>`, `0<`) require an unquoted integer before the operator — quoted integers like `'2'>file` are treated as regular arguments, matching POSIX shell behavior. The REPL shell mode is updated to handle pipeline/redirect commands, which previously failed with a `MethodError` on `length(::OrCmds)`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implement bash-style brace expansion in backtick Cmd syntax.
`{a,b,c}` expands to three separate arguments, and brace groups
participate in the existing Cartesian product logic so that
`pre{a,b}.{x,y}suf` produces all four combinations. Alternatives
support `$` interpolation, quoting, and escape sequences. Braces
without a comma (`{a}`, `{}`) are treated as literal characters,
matching bash semantics.
Unquoted whitespace inside braces is an error, following zsh.
Quoted spaces like `{"a b",c}` work as expected.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add support for bash-style brace range expansion: `{1..10}` expands
to arguments "1" through "10", `{a..z}` to "a" through "z". Stepped
ranges (`{1..10..2}`) and zero-padded ranges (`{01..10}`) are also
supported. Ranges participate in the existing Cartesian product logic,
so `file{1..3}.{c,h}` produces all six combinations.
Zero-padding pads to the total width of the wider endpoint (matching
bash/zsh), so `{-03..3}` produces "-03" through "003" (width 3).
Invalid range syntax (e.g. `{a..1}` mixing letters and numbers)
produces a parse-time error.
Differences from bash/zsh:
- Cross-case character ranges (`{a..Z}`, `{A..z}`) are an error
rather than iterating through non-letter ASCII characters.
- An explicit `+` sign on integer endpoints (`{-2..+3}`) causes
non-negative values to be prefixed with `+`. This is a
Julia-specific extension; bash/zsh do not support it.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
33b8361 to
ad10b28
Compare
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.
Summary
Implement bash-style brace expansion in backtick
Cmdsyntax, building on top of #61540.Comma expansion:
{a,b,c}expands to three separate arguments, and brace groups participate in the existingarg_genCartesian product logic, so`pre{a,b}.{x,y}suf`produces all four combinations. Alternatives support$interpolation, quoting, and escape sequences. Braces without a comma ({a},{}) are treated as literal characters, matching bash semantics. Unquoted whitespace inside braces is an error, following zsh.Range expansion:
{1..10}expands to"1"through"10",{a..z}to"a"through"z". Stepped ranges ({1..10..2}) and zero-padded ranges ({01..10}) are supported. Zero-padding pads to the total width of the wider endpoint (matching bash/zsh), so{-03..3}produces"-03"through"003".Differences from bash/zsh
{a..Z},{A..z}) are an error rather than iterating through non-letter ASCII characters betweenZanda.+sign on integer endpoints ({-2..+3}) causes non-negative values to be prefixed with+. This is a Julia-specific extension; bash/zsh do not support it.This PR was written with the assistance of generative AI.
Test plan
+signs, cross-case errors, and invalid range errors.shell_parse→cmd_genpath.