Closed snaggen closed 2 years ago
I don't think Rhai is made for a shell. It is for scripting purposes. I have plans to make one of my own. shell languages have a few builtins, a few keywords but mostly rely on other binaries in the provided PATH
variables.
Im not sure what you mean by supporting Rhai for scripting
Well, if you look at bash, it provides a quite powerful scripting language with different kinds of loops, if/switch statements, regular expressions for string manipulations and so on. So, in the end, the scripting language of a shell tend to be quite advanced. If it is possible to use Rhai for scripting it would give you quite a lot for free. Take a command line expression like: ls | xargs -n 1 | some rhai scripting
There we split up he commandline and setup the pipes, where the third is detected to not be a command so it is interpreted as a script. So the result from the xargs should be fed in to the script engine. There are still things around the scripting engine that would be needed to be handled, like storing the result in some pre-determined variable like $? in bash or $status in fish. Also, how should the pipes be passed in to the scripting engine, does it have support for reading stdin? If not, that must be hooked up aso. For rhai they have rhai-repl and rhai-run (for running as a hash bang script) that might give some ideas in to how to hold the state and so on, for integrating the script engine with the commandline.
Note, that I do not know Rhai that well, it just looked like a very interesting rust like scripting language with a lot of features, so I thought of it when I saw this shell. There are other rustlike scripting engines like Rune or Oxide if Rhai is not fulfilling the needs. But I suspect using an existing script engine is a much better way forward than trying to invent another scripting languate.
I can see where you are coming from but this is like asking bash to support python. Obviously it can be done but that would not be a shell scripting language but rather a scripting language.
For it to be a shell scripting language it first needs to check builtins, then the proper syntax, then control flow/loops etc, and if it doesn't match anything run the keyword in the $PATH variable provided
echo Hello there
It uses echo
as builtin
wget www.google.com
wget is not known syntax by the interpreter yet it is still ran through accessing the path variable
Passing stdout from other commands into stdin of rhai will be added when piping is done. Rhai is a product of its own not denying the fact that it is not good. Its just not made for a shell
imo the planned language will be just as good but without the std library and somewhat similar to bash in terms of functionality but with better syntax inspired from current day languages such as Javascript and python (don't worry it will not be indent based)
Rhai seems like a great scripting language, having a shell that uses it natively would be very interesting.