Read a from-scratch POSIX shell lexer, parser, and executor
Study a threaded PTY layer that avoids blocking on terminal IO
Run pipelines and POSIX list operators on a small custom shell
Adapt the PTY module into another C application that drives terminals
Hand-written C with a Makefile, so you need a Unix toolchain and pthreads to build.
st3sh2 is a personal project that bundles two related pieces of low-level Unix software, both written by hand in C. The author notes at the top of the README that none of the code was generated by AI, although the README itself was written by an AI for fun. The repository is the second iteration of an earlier project called st3sh. The first piece is the shell itself, also called st3sh2. The author describes it as POSIX-compliant, meaning it follows the same command language standard that bash and other Unix shells follow. It has a hand-written lexer and parser, so the user input is first turned into tokens, then grouped, and then resolved into a clean command tree before anything runs. Simple commands, compound commands, and chains joined by separators all go through the same execution path. On the feature side, the shell supports the three POSIX command list operators: semicolon for sequential runs, double ampersand for run-on-success, and double pipe for run-on-failure. Pipelines connect the standard output of one command to the standard input of the next using kernel pipes, with a forked child process per stage and the exit status of the last command in the chain becoming the pipeline's exit status. Pipelines can be nested to any depth. The full set of POSIX redirections is supported, covering output truncation and append, input from a file, stderr redirects, swaps between stdout and stderr, and arbitrary file-descriptor redirects. There are also built-in commands that have to run inside the shell process, with a help command listing them, and the usual POSIX quoting rules and word expansions. The second piece is the pseudo-terminal layer underneath, kept in a directory called pty. It manages master and slave terminal pairs and uses background threads instead of a single select or poll loop in the main thread. A reader thread streams data out of the PTY master, a writer thread drains a write queue, and thread-safe queues with condition variables coordinate them. The README says this means the calling application never blocks on terminal input or output. The author points at a POSIX.1-2017 specification link as the target for the shell and notes that a to-do list inside the repo tracks the features that are not finished yet.
Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.