Building a shell is a great exercise, but honestly having to deal with string parsing is such a bother that it robs like 2/3 of the joy along the way. I once built a very simple one in Go [0] as a learning exercise and I stopped once I started getting frustrated with all the corner cases.
Author here, and yeah, I agree. I skipped writing a parser altogether and just split on whitespace and `|` so that I could get to the interesting bits.
For side-projects, I have to ask myself if I'm writing a parser, or if I'm building something else; e.g. for a toy programming language, it's way more fun to start with an AST and play around, and come back to the parser if you really fall in love with it.
mzs 9 minutes ago [-]
Had an assignment to build a shell in a week, how hard could it be?
controlling terminal
session leader
job control
The parser was easy in comparison.
zokier 31 minutes ago [-]
Bit of pedantry but I don't think traditional unix shell (like this) follows repl model; the shell is not usually doing printing of the result of evaluation. Instead the printing happens more as a side effect of the commands.
6 minutes ago [-]
hristian 14 minutes ago [-]
The corner cases are exactly where the learning is though. Every time you hit one unquoted spaces, escaped characters, subshell expansion — you understand something deeper about how the OS actually works. The frustration is the point. Most developers never have to think about what the shell is actually doing between their keystrokes and the kernel.
gf000 8 minutes ago [-]
Not sure it tells all that much about 'how the OS works'. This is a historical abstraction that happened to look how it looks today with all its numerous warts and shortcomings.
We can easily imagine it done a better way - for all the criticism of Windows, PowerShell gives a glimpse into this hypothetical future.
Retr0id 9 minutes ago [-]
Fascinating that you resurrected an account from 2014 just for LLM spam, were the credentials compromised or something?
Rendered at 11:47:56 GMT+0000 (Coordinated Universal Time) with Vercel.
[0] https://github.com/lourencovales/codecrafters/blob/master/sh...
For side-projects, I have to ask myself if I'm writing a parser, or if I'm building something else; e.g. for a toy programming language, it's way more fun to start with an AST and play around, and come back to the parser if you really fall in love with it.
We can easily imagine it done a better way - for all the criticism of Windows, PowerShell gives a glimpse into this hypothetical future.