Greetings, HN! This is a small project I first began working on around 2022 or 2023 or so, in high school. I learned quite a bit since then but I'd like to share it here anyways.
I began to be curious about why shell languages implemented if statements and similar constructs not as plain commands in the true sense of the word (a sequence of whitespace separated tokens), but as special syntax. And I was also quite upset about the "quoting hell" in Bash and co.
So when I found out about Tcl, a language where everything is a string, including "code blocks". My first thought was "why doesn't this have pipes and execv* as first-class features like an actual shell?". And so Zrc was born.
Granted, the code is not production ready. But it's a sturdy little shell capable of some cool stuff, given that I implemented minesweeper and game of life in it, and I took the risk of daily driving it just because why not?
I've never written an interpreter before so the parsing technique may come off as ad-hoc to some, but it's certainly better than csh.
If I could have changed one thing about the design, maybe it would've been not adding expr at all. I'd have made control flow commands just call their first braced arg as a script (not as an arithmetic expression), and 0 would have been the truthy value and nonzero would be a non-truthy value (like in any other shell). I'd also have added rc's ~ command instead of regexp. And maybe I'd have replaced the <{...} and `{...} substitutions with special commands called ` and `<, to be used with [...] substitution.
edward_9x•1h ago
So when I found out about Tcl, a language where everything is a string, including "code blocks". My first thought was "why doesn't this have pipes and execv* as first-class features like an actual shell?". And so Zrc was born.
Granted, the code is not production ready. But it's a sturdy little shell capable of some cool stuff, given that I implemented minesweeper and game of life in it, and I took the risk of daily driving it just because why not?
I've never written an interpreter before so the parsing technique may come off as ad-hoc to some, but it's certainly better than csh.
If I could have changed one thing about the design, maybe it would've been not adding expr at all. I'd have made control flow commands just call their first braced arg as a script (not as an arithmetic expression), and 0 would have been the truthy value and nonzero would be a non-truthy value (like in any other shell). I'd also have added rc's ~ command instead of regexp. And maybe I'd have replaced the <{...} and `{...} substitutions with special commands called ` and `<, to be used with [...] substitution.