Also, we'll be comparing to Bash shell (src_bash[:eval yes :results output]{bash --version | head -n 1} {{{results(=GNU bash\, version 4.4.23(1)-release (x86_64-unknown-linux-gnu)=)}}}) as it is the most popular shell on the Unix world.
While there are multiple components in this project, we're focusing on two: *OSH and Oil shell*.
- *OSH is the bridge between Bash and Oil.*
It aims to be the most Bash-compatible shell that you can run most Bash scripts just fine.
The point of this component is improving what's under the hood, imposing sensible defaults on them, and getting a wide reach since Bash is the most popular shell.
While it may not run every Bash script in existence, the other point is to require minimal rewrites to run it with OSH.
- *Oil shell is the modern replacement of Bash* from its syntax and behavior.
It aims to be the shell for people familiar to Python, Ruby, JavaScript, and the like.
This is the other side of the bridge that OSH aims to reach.
Most notably, Bash splits the string when trying to do something.
#+begin_src bash
d='echo 3'
e='echo "The quick brown fox jumps over the lazy dog."'
parallel -- $d $e
#+end_src
It should throw an error because =parallel= interprets it as if it has 4 arguments due to the splitting — i.e., ~parallel -- echo 3 echo "The quick brown fox jumps over the lazy dog."~.
The solution here is to quote the variables in evaluation (e.g., ~parallel -- "$d" "$e"~).
Compare that to Oil...
#+begin_src oil
var d = 'echo 3'
var e = 'echo "The quick brown fox jumps over the lazy dog."'
parallel -- $d $e
#+end_src
If you want splitting, you could use =split= Oil function — e.g., ~@split(array_var)~.
- There are different ways [[https://www.oilshell.org/release/latest/doc/syntactic-concepts.html][how Oil can create an expressive language with the shell]].
It can parse different sublanguages with different lexer modes.
But there are dominantly two modes to keep in mind: expression and command mode.
While Bash have support for structured data such as arrays and associative arrays, it does not go any further such as not letting you assign arrays in an item.
As of v0.8.9, Oil also comes with the same problem but it seems [[https://github.com/oilshell/oil/issues/741][the developer is also interested in solving that]].
Though, you can still declare and assign variables with nested data structures.
#+begin_src oil
const author = {
"name": "John Doe",
"birthdate": "1992-04-04",
"portfolio": [
{ "title": "Philistine: A Jon Doe story", "isbn": "392-423-2113-123" },
This is handy as most tools has an option to print JSON data — e.g., =systemctl=, Ripgrep, =buku=, [[id:8135ece9-0dc0-4799-ac63-a24f9486ddd2][BorgBackup]].
- Oil seems to evaluate in applicative order, evaluating only when the conditions passed — e.g., ~echo $['' + null if null else 'EEEEHHH']~ should print =EEEEHHH=.
+ Just like most modern mainstream languages... nice.
- Two operands of different types are considered unequal — e.g., ~'4' == 4~.
+ You can use Python-like type conversions like =Int=, =Bool=, and =Str= — e.g., ~Int('4') == 4~.