Skip to content

Allow $() in command position - #12829

Draft
krobelus wants to merge 3 commits into
fish-shell:masterfrom
krobelus:command-substitution-in-command-position
Draft

Allow $() in command position#12829
krobelus wants to merge 3 commits into
fish-shell:masterfrom
krobelus:command-substitution-in-command-position

Conversation

@krobelus

Copy link
Copy Markdown
Contributor

We allow "$var" in command position but not "$(somecmd)".

The latter is usually not something you'd want to use interactively, because command-specific completions don't work because fish won't expand command substitution until the user presses enter.

On the other hand, this can be handy for scripts to be able to inline some local variables (see next commit).
Also, it might be useful for pasted commands.
Also, the behavior of "$(somecmd)" should be obvious.

Allow it. For now, don't allow "()" in command position because it
means something else in POSIX-style shells.

This patch extends some of our old hacks to string expansion, but
existing code paths should be untouched.

Closes #5575

krobelus added 3 commits June 22, 2026 15:13
We allow "$var" in command position but not "$(somecmd)".

The latter is usually not something you'd want to use interactively,
because command-specific completions don't work because fish won't
expand command substitution until the user presses enter.

On the other hand, this can be handy for scripts to be able to inline
some local variables (see next commit).  Also, it might be useful
for pasted commands.

Also, the behavior of "$(somecmd)" should be obvious.

Allow it. For now, don't allow "()" in command position because it
means something else in POSIX-style shells.

This patch extends some of our old hacks to string expansion, but
existing code paths should be untouched.

Closes fish-shell#5575
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.

Allow command substitution with command builtin

1 participant