Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add experimental [no-shell] attribute #2531

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Add experimental [no-shell] attribute #2531

wants to merge 1 commit into from

Conversation

casey
Copy link
Owner

@casey casey commented Dec 19, 2024

This PR adds an experimental [no-shell] attribute.

When the [no-shell] attribute, linewise recipe lines are not run with sh (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 for uv. Because just 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:

  • Single and double quoted strings with the usual semantics
  • Environment variable access with $VAR
  • Selectively joining the result of {{…}} interpolations with adjacent text, depending on whether it's whitespace separated or not
  • Making unsupported shell syntax an error, instead of passing unwanted arguments (so echo hello > foo is an error, instead of calling echo with hello, >, and foo)

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. If sh is not available, any other shell or interpreter can be used. So this covers a pretty niche use-case. Also, I'm not sure just is a good fit for uv, 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.

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