-
Notifications
You must be signed in to change notification settings - Fork 476
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
[script]
recipes
#1413
Comments
Is this a common tripping hazard for new users? TBH, this doesn't resonate with me as a a big pain point that is worth the loss of functionality (no interpolation, no echoing, have to remember to export variables) with not much new functionality enabled, complexity added in the interim:
I already avoid shebang recipes as much as possible: (1) too many footguns in shell scripts (2) justfiles are not good development environments for complex scripts. I can already write a shell script and execute it from My suggestion would be to instead aim to not send users to shebang/script recipes. In that context, I would like to make it easier to treat other recipes in the file as functions -- not necessary syntactically, but in the sense of making it easy to compose complex recipes from simpler ones; there are some awkward edges like requiring |
I should go back and look at issues, discussions, and discord chat, but just going on memory, there are some common tripping hazards that this would avoid:
It would be interesting to see how common shebang recipes are. One could use janus to find out. Can you elaborate on the downsides? You mentioned loss of interpolation, echoing, and exporting variables:
|
By the way, thanks for the detailed feedback, I really appreciate it! |
Going in the other direction, I miss interpolation outside of recipes, concatenation is more verbose (#11). If this feature got added, we'd have the inverse confusion - why isn't
I'm not understanding how |
Interesting point. I'm not sure if users would want
I wasn't very clear, but I mentioned this because it's one of the main reasons that users need shebang recipes. |
I'd just like to point out that the current setup allows interpolation in all recipes, so the syntax is able to deal with that very simply. If it were possible for some recipes to disallow interpolation, it wouldn't be at all straightforward for the syntax to distinguish those. We'd have to branch at the point of the I'm not taking a position on whether the attribute is worthwhile, but if there's not a clear case for it then my preference would be to not add it. |
I'm looking forward to seeing this implemented, this is my biggest hurdle with just right now. registry_main := "registry_main URL"
publish reg:
./scripts/publish.py {{ if reg == "main" { "{{registry_main}}" } else { "{{reg}}" } }}
|
I'm now leaning towards not doing this, and instead adding a [script] recipe annotation which is simply a way to create a shebang recipe with cross-platform syntax, see #1479. |
Existing recipes, both shebang and linewise, have some issues:
The issues:
{{…}}
interpolations inside of recipe bodies. This requires escaping{{
inside recipe bodies, which is awkward.{{…}}
contain quotes, spaces, or other special characters, quoting is quite tricky.\
must be used to escape multi-line constructsThe proposal:
[script]
annotationsh PATH_TO_SCRIPT
, and do not take shebang lines[script("bash", "-i")]
or a global setting that changes the default script interpreter{{…}}
inside of script bodiesset positional-arguments
is always turned on for scripts, so arguments are accessed with$1
,$2
, etcDownsides:
just
echoes each recipe line before running it. This would not be possible for scripts. However, a script could useset -x
to turn this on. Additionally, there could be a global script prefix, which could default to something likeset -euxo pipefail
.Eventually,
[script]
recipes could be made the default recipe type in a future just edition, and linewise and shebang recipes could be deprecated. The migration process would look like this:[script]
recipes behind the--unstable
flag[script]
recipes once they're working well[legacy]
, for the current default recipe type[script]
recipes the defaultMigration would be easy. Users could add the
[legacy]
annotation to their recipes, update to the new edition, and convert[legacy]
recipes to[script]
recipes at their leisure.I'm very interested in feedback on this!
The text was updated successfully, but these errors were encountered: