News for hackers. Stuff that matters.
Re:C89cc.sh – standalone C89/ELF64 compiler in pure portable... by redoh on Friday April 03, 2026 @06:26AM (#47625016)
Writing a C compiler in pure shell is one of those projects that sounds absurd until you think about bootstrapping. If you want to compile C on a system where you literally have nothing but a POSIX shell, this is exactly what you need. The fact that the parser itself is BNF-generated from shell modules makes it even more interesting as a study in how far you can push shell scripting before it breaks. Would love to see this evolve into a proper repo with tests so it can actually serve as a minimal bootstrapping tool.
Re:C89cc.sh – standalone C89/ELF64 compiler in pure portable... by xonix on Friday April 03, 2026 @07:41AM (#47625534)
But how would POSIX shell be available? Wouldn’t it be compiled from C?
Re:C89cc.sh – standalone C89/ELF64 compiler in pure portable... by laurenth on Friday April 03, 2026 @09:33AM (#47626494)
A shell is almost always used to setup the bootstrap environment, so the dependency on a shell is more or less always there.

Otherwise, something special with POSIX shell is its large number of independent implementations, making it the ideal starting point for diverse double-compilation (https://arxiv.org/abs/1004.5534). The idea is to bootstrap a toolchain from multiple compilers (shells in this case), and the result compared to verify that no shell introduced a trusting trust attack.

Re:C89cc.sh – standalone C89/ELF64 compiler in pure portable... by lpribis on Friday April 03, 2026 @07:38AM (#47625512)
I don't think any realistic system will bootstrap C from shell. What is the shell implemented in if not C?
Re:C89cc.sh – standalone C89/ELF64 compiler in pure portable... by gaigalas on Friday April 03, 2026 @08:35AM (#47625966)
This shell.c can be compiled from c89cc.sh itself:

https://gist.github.com/alganet/1513d7b6abef5c1a53a324d897c3...

Ouroboros self-hosting. They can self-host one another.

The idea is to make shell.c compile from an even simpler C compiler, such as M2-Planet:

https://github.com/oriansj/M2-Planet

Let me remind you that current stage0 bootstraps tinyc from mes, which is an interpreted lisp. It's not that different from the shell architecturally.

The current stage0 also features kaem as one of the first dependencies. kaem is, in fact, a simpler version of the bourne shell.

It's always a tower. You'll never get a one single clean dependency pass in bootstrapping.

Re:C89cc.sh – standalone C89/ELF64 compiler in pure portable... by zhongwei2049 on Friday April 03, 2026 @09:18AM (#47626367)
The shell.c ouroboros is really cool. Being able to bootstrap trust through an entirely different language family (shell → C → shell) adds genuine value to the trusting-trust problem beyond just technical novelty.
Re:C89cc.sh – standalone C89/ELF64 compiler in pure portable... by cestith on Friday April 03, 2026 @10:24AM (#47627002)
Even if your shell was compiled in C, it doesn’t mean it wasn’t cross-compiled from another platform.
Re:C89cc.sh – standalone C89/ELF64 compiler in pure portable... by lioeters on Friday April 03, 2026 @10:14AM (#47626890)
> bootstrapping

This project reminds me of:

The Design of a Self-Compiling C Transpiler Targeting POSIX Shell - https://dl.acm.org/doi/10.1145/3687997.3695639

It's not just a toy or a fun hobby project, there's potential for practical use as a step in bootstrapping an entire software stack from human-verifiable artifacts.

Re:C89cc.sh – standalone C89/ELF64 compiler in pure portable... by wahern on Friday April 03, 2026 @01:38PM (#47629636)
It's an ongoing project: https://github.com/udem-dlteam/pnut

See also pnut.sh, but the server seems to be down at the moment.