Top
Best
New

Posted by ingve 11 hours ago

Building a Shell(healeycodes.com)
139 points | 31 commentspage 2
zokier 10 hours 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.
jermaustin1 9 hours ago||
I remember my first shell programming I ever did was batch in windows back in the 3.11/95 days.

The first line was always to turn off echo, and I've always wondered why that was a decision for batch script. Or I'm misremembering. 30 years of separation makes it hard to remember the details.

enoint 8 hours ago||
Echo in that case prints command lines before executing them. Its analog is `set -x` rather than `echo`.
skydhash 8 hours ago|||
It’s a shell, not the whole thing. The whole thing is the shell+kernel+programs.
themafia 2 hours ago|||
It prints a prompt.
dirk94018 6 hours ago||
Interesting. I wanted to do toast | bash to let the AI drive the computer but the bash shell really got in the way. Too much complexity. The things that annoy humans, $ expansion, special characters, etc don't work for AI either. Ended up writing a custom shell for AI (and humans). When a tool gets in the way, sometimes it just time to change the tool.
austy69 8 hours ago||
Fun read. Wonder if you are able to edit text in the shell, or if you need to implement a gap buffer to allow it?
healeycodes 8 hours ago|
Editing the current line works because I brought in https://man7.org/linux/man-pages/man3/readline.3.html towards the end so I could support editing, tab completion, and history.

IIRC readline uses a `char *` internally since the length of a user-edited line is fairly bounded.

zokier 2 hours ago|||
worth noting that you get basic line editing for "free" from kernels tty subsystem even if you don't use readline.
austy69 7 hours ago|||
Very cool. Currently working on the beginning of a small text editor so this part seemed interesting and was curious of any overlap. Thanks for the interesting post!
stainlu 3 hours ago||
[dead]
rigorclaw 9 hours ago||
[flagged]
leontloveless 9 hours ago||
[dead]
hristian 9 hours ago|
[flagged]
jmmv 9 hours ago||
Somebody blamed this comment on LLMs, and maybe/probably it is, but I think the first sentence is spot-on so I thought it was worth replying to.

Dealing with the corner cases ends up teaching you a lot about a language and for an ancient language like the shell, dealing with the corner cases also takes you through the thinking process of the original authors and the constraints they were subject to. I found myself in this situation while writing EndBASIC and wrote an article with the surprises I encountered, because I found the journey fascinating: https://www.endbasic.dev/2023/01/endbasic-parsing-difficulti...

gf000 9 hours 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 hours ago||
Fascinating that you resurrected an account from 2014 just for LLM spam, were the credentials compromised or something?
IncreasePosts 9 hours ago||
Maybe the author had it logged into something that their claw had access to