Comments (8)
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 [script]
attribute and create a category of non-interpolation recipes which duplicate the recipe code. I'm not sure it would be worth the effort.
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.
from just.
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.
from just.
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:
-
interpolation of
{{ }}
and escaping: I do use this interpolation more often than I escape it. Perhaps the flag we're looking for isno-interpolation
instead -
shebang line/interpreter customization -- has not been a problem for me (but I don't use
just
on windows) -
set positional-arguments
: I haven't understood why this isn't on by default - is there a downside?
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 just
if needed.
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 -f {{ justfile() }}
, constructing arguments by string concatenation, conditionals being expressions.
from just.
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:
- Very common: Confusion about how to prevent
{{…}}
interpolations from being split by the shell. Needing to use'{{…}}'
, which is pretty ugly and verbose, doesn't work if an argument has'
in it. - Very common: Desire to set variables in the middle of a recipe.
- Occasional: Shebang inconsistencies.
set positional-arguments
isn't the default just because it can break some custom shells (namely old versions of powershell), but it's likely to become the default in a new edition.
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:
- Loss of interpolation:
{{FOO}}
would be replaced with$FOO
(or$N
if FOO is an argument), which is shorter and is the normal shell syntax. - Echoing:
just
could define a[script]
recipe prelude which would be inserted at the beginning of script recipes. This could includeset -x
, which would turn on command echoing. - Exporting variables: In a future edition,
set export
could become the default, so you wouldn't have to remember to export variables.
from just.
By the way, thanks for the detailed feedback, I really appreciate it!
from just.
- Interpolation: I understand that with
positional-arguments
andexport
, we could get rid of interpolation for variables; what about for functions or expressions? ex{{ invocation_directory() }}
?
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 {{..}}
working in my recipe?
- Desire to set variables
I'm not understanding how [script]
will address this trip hazard: it doesn't make it easier or eliminate the confusion between just variables and shell variables.
from just.
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 {{..}} working in my recipe?
Interesting point. I'm not sure if users would want {{…}}
inside recipes, since the shell usually provides functionality to manipulate strings.
I'm not understanding how [script] will address this trip hazard: it doesn't make it easier or eliminate the confusion between just variables and shell variables.
I wasn't very clear, but I mentioned this because it's one of the main reasons that users need shebang recipes.
from just.
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}}" } }}
>>just publish main
>>./scripts/publish.py {{registry_main}}
from just.
Related Issues (20)
- Pass `--check` output to `stdout` HOT 1
- Cargo install fails with latest on Ubuntu 22.04 HOT 4
- Container image HOT 5
- "just --list" should list fallback recipes HOT 1
- The fallback example on the README.md no longer needs the --unstable flag HOT 1
- Need way to suppress "Trying ../justfile" output when fallback occurs HOT 3
- When piped using `|` `just --list` should output targets in a list omiting the `Available recipes:` text HOT 5
- Calling another recipe from an initial recipe for Python HOT 2
- just path/to/recipe and (cd path/to; just recipe) should be equivalent HOT 3
- just could not find the shell: program not found HOT 1
- Github release for 1.12.0 HOT 2
- cannot pass . as an argument from one justfile to another HOT 1
- ubuntu install fails HOT 2
- feature request: function to get repository root directory HOT 5
- bug: new "conflicting path arguments" error in 1.12.0 HOT 5
- just --list should display first line of multi-line comment HOT 1
- Pre-built binary install script does not work on MacOS Ventura HOT 2
- Should be able to combine multiple attributes (e.g., [private], [no-cd], etc.) on single line
- Dependency in other directory HOT 2
- how to load environment variables from a secrets manager ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from just.