Repository navigation
run cargo update to reduce the size of Cargo.lock - #8
Closed
WindSoilder wants to merge 1 commit into
Closed
WindSoilder wants to merge 1 commit into
WindSoilder wants to merge 1 commit into
Conversation
fdncred
added a commit
that referenced
this pull request
May 6, 2026
## Description
This PR adds dynamic builtin dispatch for the percent sigil so users can
write:
- %($cmd) arg1 arg2
- %$cmd arg1 arg2
Previously, percent dispatch only worked when the command name was
statically known at parse time. With this change, the builtin name can
come from a runtime expression while still preserving percent semantics:
resolve and run builtin commands only.
<!--
Explain what this PR does and why.
This section is intentionally flexible:
- Describe the problem
- Explain your approach
- Include technical details if relevant
Good examples:
- "In this PR, I fixed..."
- "In this PR, I added support for..."
- "This change improves X by..."
Write as much or as little as needed for reviewers to understand your
changes.
-->
## User-facing changes (Release notes)
Nushell now supports dynamic percent builtin dispatch with forms like
%($cmd) and %$cmd.
This preserves percent safety semantics while allowing runtime command
selection:
- only builtins are eligible targets
- non-builtin/custom/alias targets are rejected
- arguments are forwarded as parsed values (not string-evaluated like
shell eval)
This should work very similarly to dynamic dispatch of externals. The
same model was followed to implement it.
Here's a couple examples that are also tests.
### Built-ins resolve
```nushell
❯ let cmd = 'echo'; %$cmd 'hello'
hello
❯ %('echo') 'world'
world
❯ let cmd = 'echo'; %($cmd) 'hello'
hello
```
### Missing commands fail
```nushell
❯ let cmd = 'my_nonexistent_cmd'; %($cmd)
Error: nu::shell::command_not_found
× Command not found
╭─[repl_entry #7:1:33]
1 │ let cmd = 'my_nonexistent_cmd'; %($cmd)
· ───┬───
· ╰── command not found
╰────
```
### Custom commands aren't built-in commands so they fail too
```nushell
❯ def custom_cmd [] { 'nope' }; let cmd = 'custom_cmd'; %($cmd)
Error: nu:🐚:command_not_found
× Command not found
╭─[repl_entry #8:1:55]
1 │ def custom_cmd [] { 'nope' }; let cmd = 'custom_cmd'; %($cmd)
· ───┬───
· ╰── command not found
╰────
```
<!--
This section is used (mostly as-is) for https://www.nushell.sh/blog/
Describe how Nushell behavior changes from a user's perspective.
Do NOT describe internal Rust changes here.
Write in a release note style, for example:
- "Added support for..."
- "Fixed an issue where..."
- "Nushell now supports..."
- "Improved performance of..."
If your changes do NOT affect users (internal refactors, cleanup, etc.),
just write:
- "n/a"
- "nan"
- or similar
This tells us the change should not appear in the changelog.
Tips:
- Focus on observable behavior
- Include examples if helpful
- Keep it concise
You can:
- Write a short paragraph (will appear as a bullet point), OR
- Use headings (###) if your change needs more structure
Avoid writing things like:
- "In this PR, I refactored..."
- "This updates internal code..."
You may leave this blank until the PR is ready.
-->
## Additional notes
closes nushell#18150
<!--
Optional.
Examples:
- fixes nushell#123
- closes nushell#456
- related nushell#789
Anything else reviewers should know.
Remove this section if not needed.
-->
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.
No description provided.