r/programming • u/oilshell • Feb 08 '19
How to Parse Shell Like a Programming Language
http://www.oilshell.org/blog/2019/02/07.html3
u/colelawr Feb 08 '19
Keep up the great work! I'm following along on proglangs, too
2
u/oblio- Feb 08 '19
Yup, same. I can't really contribute since it's not my area of expertise (I don't think I'd even be suited to work on programming languages), but it is still fascinating.
I hope an official release is made at some point with a somewhat stable shell. I'd run it on Cygwin, even daily.
0
Feb 08 '19
[deleted]
4
u/oilshell Feb 08 '19
Yes, shell has terrible syntax, and the goal of the Oil project is to replace it with something better. That can only be done by incrementally migrating away from it.
I wrote a post that explains the issue you bring up.
[is the same astest.[is not special in shell, it's treated likelsorgrep.2
u/max630 Feb 08 '19
For language syntax like "{" or "(" you don't need to use space.
'[' is not a language syntax but rather a command, so it is nothing special compared to '[foo' or 'foo['. You can avoid confusion by just using
testcommand instead :)1
u/oblio- Feb 08 '19
That's even worse design, having [ as a command. Same for . being an alias (?) for source.
We forgive shell for a lot of crap because:
they didn't really know any better at the time
it's pre-installed on every non-Windows system (Stockholm syndrome)
0
u/max630 Feb 08 '19
There is third reason: primary shell's use is interactive command-line. If you need to write programs it is probably not the best option.
2
u/oblio- Feb 08 '19
I don't buy that third reason. [ could be some sort of special shell construct or whatever.
As I was saying: "they didn't really know any better at the time".
It's not like having a typo mess up your command is a design decision to improve the command line usage (space next to [). Same goes for environment variables requiring no spaces next to the equals sign.
Most likely, on the crappy computers they had at the time, with the crappy keyboards and low resolution, low refresh rate screens, implementing [ as a command was easier and faster. Worse is better :)
2
u/o11c Feb 08 '19
I'll probably wait for the fast version, but this is definitely exciting.
Random question related to parsing ... does it know to stop after an unconditional
exitto support the "concatenate a zip file" thing?