1. 7

  2. 2

    The title is a little misleading as Oil is yet another shell, so it’s not so much “improving a Bash script using Oil” as it is “replacing a Bash script with an Oil script”.

    1. 2

      That’s true, but you can also use Oil just to improve a bash script… just parsing or running it with Oil may make the script more comprehensible, and less reliant on the vagaries of bash (which do change from version to version). Example with a Lisp in bash:


    2. 2

      As always, I compare other shells to my Next Generation Shell.

      $ cat p.ngs 
      #!/usr/bin/env ngs
      script = fetch("package.json").scripts[ARGV[0]]
      log: bash -c $script


      ./p.ngs 'say hello'
      [LOG 2020-09-30 08:17:45 IDT] Running command: bash -c echo\ \"Hello\ world\!\"
      Hello world!


      • No variable expansion bomb. $script would be "$script" in bash
      • Data structures
      • JSON support


      • No bash compatibility in NGS (hence bash -c)
      • Programming language less similar to bash


      • log: prefix before command. It is common to want to print the command before execution so it’s in. The language facility is supporting SOMETHING: syntax before commands. The next level is the log itself.
      • fetch() knows it’s JSON by looking at extension and you don’t have to specify