-
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
Is adding the ability to run commands without a shell worth it? #2532
Comments
Well worth it especially since the core collection of required utilities can be very easily incorporated using already-existing permissively-licensed opensource code. Otherwise, hard to beat Makefile for non-trivial complexity |
Hi, took me a while to check this. It does look interesting, but in the end you will basically be implementing your own shell in rust as you suggested. You will eventually need at least handle pipes, &&, ||, file redirects. All of those with their own idiosyncrasies. Which in my opinion is not a bad thing, but you need to know if you want basically a side project. I do not believe you need a full fledged shell, with all the control mechanism like for/if/switch and so on. But in case you do, maybe it is better to use something else like nushell which is written in rust (could it be imported as a lib?). One thing to keep in mind is that a task runner should be one the 1st things that get installed therefore the fewer external dependencies it has the better. |
@inoa-jboliveira Definitely agreed on the possibly infinite scope. My thinking is that the goal is just to get it to the point where simple commands function, and if you need more, you need to install a shell. I've thought about If someone wanted to open a draft PR with an experimental integration, I would definitely be curious, but I might not merge it, unless it was incredibly compelling. |
I tried using [no-shell] with this version and could not avoid a parse error. Is there a trivial example I can try? Re built-in capabilities, wouldn't there be value in even a limited implementation that only had an expression processor (rather than a shell)? For example, a drop-in evaluator such as jaq https://github.com/01mf02/jaq (not suggesting you use that-- but mention for discussion's sake) could be used to provide all the variable / string / expression manipulation and generate a result that is simply printed. While this may seem trivial, if the goal is "run commands with no external dependencies, other than the commands themselves", then wouldn't that alone achieve the goal by enabling In addition, if the evaluation engine supports looping, then it might also provide a solution to #1570. |
@liquidaty What error are you getting? This works for me: [no-shell]
foo:
echo hello
echo {{"goodbye"}} I think the goal is to make it easy to run commands without needing a shell, without changing the general workflow of running |
@casey thank you that works. I was trying to use
Is "echo" a built-in command? if so, where in the code is it defined or where would I find what other commands can be used with [no-shell]? |
I believe I have a python script #!/usr/bin/env python3
import os, sys
from pathlib import Path
def bins():
for component in os.environ["PATH"].split(os.path.pathsep):
path = Path(component)
if not path.is_dir():
continue
for entry in path.iterdir():
if os.access(entry, os.X_OK):
yield entry
argc = len(sys.argv)
if argc == 1:
for bin in bins():
print(bin)
elif argc == 2:
for bin in bins():
if bin.stem == sys.argv[1]:
print(bin)
break
else:
sys.exit(1) |
Sorry, I'm an idiot, I was misunderstanding what "no-shell" means but I get it now. And my brain was stuck in |
Hi, I wanted to share this: https://fishshell.com/blog/rustport/ Fish has a much more sensible format than nushell IMO and is more widely adopted. I had no idea they were re-writing it in rust. Also no idea if you can use it as a crate (possibly a stripped out version?) |
@inoa-jboliveira one concern I would have (though my opinion should not be counted for much) about fish is that it can't run on windows. I do not use windows directly myself, but it is an unavoidably necessary build target (in fact, if I had to pick only one platform, I would have no choice but to pick Windows-- for that reason, I can't use Then again, if in getting to the "stripped out" version you mention, the non-portable bits can be excluded, then maybe Win compatibility could be retained. |
Yah, Fish is awesome, but unfortunately the goal with the no-shell mode is being cross-platform, and Fish doesn't support Windows. |
Incomplete initial implementation in #2531. Needs at least string parsing, environment variable access, and throwing an error on unsupported shell constructs to be useful.
I'm honestly not sure it's worth it. It's very easy to get a working
sh
almost everywhere, so this is useful only for those niche cases where it isn't possible.The text was updated successfully, but these errors were encountered: