-
Notifications
You must be signed in to change notification settings - Fork 510
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
Remove dependency on sh
#161
Comments
I think a cool way would be to let you choose shell. And then it would start the shell and pass commands to its STDIN. This way it wouldn't fork it every time, and also wouldn't be too much work, AND also would be simpilest to implement. |
@legolord208 I think that would be a neat, although I'm hoping to make just as cross-platform as possible. If we allowed using any shell, then it would also require that that shell be installed wherever the justfile was run. |
@casey OK. I might be able to set up some parser PR some time later. How would you like the syntax? EDIT: Like, what happens if you mix quote and not quote like |
@legolord208 I've been wanting to do this for a while, but I think it's too massive of a project to be done in a single PR. Also, I'm hoping for strict compatibility with an existing shell, either dash (the debian almquist shell, and the standard |
The exact functionality of |
@tbodt Ouch, that sounds like a lot of work :O |
Yeah, shells do a lot of stuff! If you're interested in tackling writing a shell in rust, I'd suggest making it its own project. |
@casey Oh, yeah! Perhaps there could be a flag to use ion as shell. Not sure if it has any way to communicate with Rust, but it would be cross-platform 👍 |
A posix shell parsing library in Rust sounds like a useful thing. Not sure if it exists. |
@jD91mZM2 ion is not aiming for POSIX compatability (which I assume to be important for Just based on previous comments). There is cicada, which calls itself a subset of bash, but as of today it is rather a POC. Neither support windows. For anyone seriously attempting this, I suggest taking a look at oil. It aims to be a superset of bash in order to gradually replace it with saner syntax. It is a C/Python project but take a look at andyc's blog to understand what a massive endeavor this kind of project really is. |
I just released v0.5.0, which includes the ability to set the shell used for recipes and backticks on a justfile-wide basis. This gives I think this sort-of addresses this issue, since I opened #531 to track the issue of cross-platform justfiles (I also included a summary of the discussion and design from this thread) and #534 to track the wishlist item of bundling a shell and userland with just. I hope the new |
sh
isjust
's only significant dependency. I've been thinking for a long time that it would be nice to get rid of it.I think the best way would be to write a shell library in rust. It would probably be easiest to make it a drop in replacement for dash. It could be integrated as a library to avoid having to fork a new binary to run each command.
Some benefits of this would be:
sh
cd
ing in recipes don't work as one would expect, since each line is executed by a new shell. If instead some kind ofsh
library were used, these could be made to work with the expected semantics$NAME
sh
library will be doing the parsing, multi-line constructs would not need to be backslash escapedAdditionally, I think that such a project would have a lot of utility outside of just.
sh
is one of the most important programs on a system, and writing it in a more secure language like rust would have a lot of benefits. It might be possible to add a lot of aggressive optimizations, features which aren't feasible in C. Also, although the base library would have a very small feature set, and would be a drop in replacement fordash
, with the ability to add plugins, it could be the starting point for a more feature rich shell.One difficult constraint is that we currently depend on Cygwin on Windows. Cygwin binaries contain a system call translation layer, which allows them to use unix paths and a unix userland on windows. If we wrote our own shell we would have to figure out how to continue to provide this functionality.
The text was updated successfully, but these errors were encountered: