Since coming back, I've been slogging through the shell.
I made a "complete pass" over the front end, fixing various problems and polishing error messages.
I also touched the runtime. It reminded me that I haven't written much about the shell-runtime.
I don't think I will do that, because silly problems drop out of hat. I would rather work on the Oil language. (I've also been working on the OSH-to-Oil translator.
But here is a list of difficult issues.
Static parsing. However see below about alias.
There is a small exception to the LST invariant, but the overall principle holds.
I wrote this arena invariant test.
I just fixed a bug with this, and it reminded me how complicated it was.
splitting and globbing , but "reframing"
word is composed of word_part
word part evaluates to part_value
part_vals get reframed into frames
then unquoted ones get split
splitting involves an explicit state machine that creates spans
IFS chars vs. IFS whitespace
IFS=': '
argv.py 'a : b : c :' argv.py 'a : b : c '
[[ ]] vs [ ]
$'foo\n' vs echo -e 'foo\n'
$(( )) vs expr (not in shell, but I implemented it for toybox)
Corrolary: find is a dynamic expression language, and we should have a statically-parsed variant of it!
Advertise: looking for someone to implement find/xargs
TODO: better terms than static and dynamic.
${a ## }
Good thing: Oil no longer depends on Python's regex implementation. Only libc's.
These string ops are deprecated, and I will provide more powerful ones in Oil.
Back to FD bug. OSH Runs Real Shell Programs
It happened asgain! Twice!! Why didn't I think of it?
It required two fixes for two bugs.
LST makes it easy for many cases.
However other cases are hard:
lesson: use tokens everywhere, e.g. for redirects. TODO: for arithmetic.
It makes parsing undecidable. See this parsing shell paper.
However it depends on how you define the problem.
Not going to solve this
Need some kind of TLA+ formalism.
Looking at all the global variables in bash/dash etc. makes my eyes glaze over. That might be my own issue.
Oil is all abou testing. I'm having trouble imaginging how I would test this.
This is the last use case for the parser.
The shell still needs another pass over this. I will probably throw out Python's implementation and make my own.
However, I like the fact that you can git clone Oil and run bin/osh and get
started roughly. So it's not clear exactly how this will play out.
I'm still on the first one. What about Scala-LMS? Can I do something there?
Oil is a project of DSLs.
Very happy with (this should be a separate blog post)
Unknown:
Glad I changed:
I used return codes because I thought I would translate.
However if you know anything about compiling exceptions to control flow, let me know!
I'm learning about control flow graphs, the EmScriptem algorithm, WebAssembly, etc.
I haven't
Multiple invention!