Plan for sourcing/translating sh scripts?
Once general concern that I have so far is that Ion introduces a lot of idiosyncratic behavior. It’s neither a Rust REPL with a subset of the language, but it also isn’t compatible with sh either. It’s kind of a mix of concepts of both. This introduces an additional barrier to learning and adoption.
One particular issue is that a lot of packages will install a shell script to set up environment variables etc. For instance, nix. There doesn’t seem to be any good way to source this file, and translating it currently would require rewriting it by hand (and potentially manually updating it if it changes).
A few thoughts I had:
- An external translation application that can easily be used with a source directive
- An sh-compatibility mode that can be invoked through use of a special sh directive
- An sh-compatibility mode triggered by the shebang (this might still require annotating files, but be O(1) every time)
- An extraction mode that actually forks an sh-compatible shell, then extracts default/new/specified environment variables at the end of that process back into the Ion environment
To keep the scope manageable, if it’s a pain to parse sh, you could probably get away with providing a subset of the most commonly used language features.