Building a Shell

Coffee-fueled toy terminal sparks pedants, power-users, and a spicy LLM accusation

TLDR: A coder built a small command-line shell to run basic commands, showing how quickly simple ideas get tricky. Commenters argued over what a shell really is, warned that parsing is pain, debated PowerShell vs. Unix tradition, and even lobbed an LLM-spam accusation—proof that shells spark strong opinions

One early-morning coder brewed coffee and built a tiny command-line shell—basically the text window where you type “ls” and “echo.” The project, andsh, reads a line, splits it into words, and runs programs, with plans for pipes later. Simple idea, cozy vibes… until the comments exploded.

First, the pedants pounced: one voice insisted “shells aren’t REPLs” (a REPL is a loop that reads, evaluates, and prints), arguing the printing is done by commands, not the shell. Then came the battle-weary builders warning that string parsing steals the joy—corner cases galore—and a veteran dropped a boss-fight checklist: controlling terminals, sessions, job control. Translation: the “hello world” of shells turns into a hydra fast.

Meanwhile, a future-vs-past showdown kicked off. Critics said this won’t teach you how operating systems really work, calling the shell a quirky relic; fans of Windows’ PowerShell chimed in as the “better future.” And just when it felt wholesome, a commenter tossed in a spicy accusation about “LLM spam” and an old account, prompting eye rolls and popcorn emojis. Verdict from the crowd? Cool project, hard road—and even harder debates. The shell may be tiny, but the comment drama was supersized

Key Points

  • The shell is implemented in C with a prompt-driven loop that maintains last_status and running state.
  • Input is tokenized by splitting on whitespace and separating the '|' token; quoting and redirections are not yet supported.
  • The built-in 'exit' stops the shell; all other commands run as external programs via fork and execvp.
  • The parent waits for the child using waitpid, storing the exit status for features like $? .
  • On exec failure, the child prints an error and exits with 127 (ENOENT) or 126 (other invocation errors); EINTR during waitpid is handled.

Hottest takes

"Shells aren’t REPLs; commands do the printing" — zokier
"resurrected an account from 2014 just for LLM spam" — Retr0id
"PowerShell gives a glimpse into this hypothetical future" — gf000
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.