Add experimental [no-shell] attribute #2531
Draft
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.
This PR adds an experimental
[no-shell]
attribute.When the
[no-shell]
attribute, linewise recipe lines are not run withsh
(or whatever the shell is set to) but instead is run with a very simple command parser and interpreter.The goal is to provide the ability to run commands with no external dependencies, other than the commands themselves.
This came up in astral-sh/uv#5903 when discussing the possibility of using
just
as a command runner foruv
. Becausejust
relies on a shell,sh
by default, to run commands, it can't be used by projects which must be cross platform with no other dependencies.This PR, which isn't really mergable at the moment, only supports word splitting on whitespace and
{{…}}
interpolations.For this to be minimally useful, I think it also needs to support:
$VAR
{{…}}
interpolations with adjacent text, depending on whether it's whitespace separated or notecho hello > foo
is an error, instead of callingecho
withhello
,>
, andfoo
)I've been hoping for a long time that a Rust-only bourne shell would be written, but that doesn't appear to be happening, thus this PR.
I'm not sure if this PR is worth it, to be honest. There are a ton of ways to get a working
sh
, in almost every environment. Ifsh
is not available, any other shell or interpreter can be used. So this covers a pretty niche use-case. Also, I'm not surejust
is a good fit foruv
, even if this feature was available.Also, this feature would have to be unstable for a long time, until we were sure that we had added everything that we wanted to the shell language.