Executable formal semantics for the POSIX shell
Michael Greenberg, Austin J. Blatt
Abstract
The POSIX shell is a widely deployed, powerful tool for managing computer systems. The shell is the expert's control panel, a necessary tool for configuring, compiling, installing, maintaining, and deploying systems. Even though it is powerful, critical infrastructure, the POSIX shell is maligned and misunderstood. Its power and its subtlety are a dangerous combination.
We define a formal, mechanized, executable small-step semantics for the POSIX shell, which we call Smoosh. We compared Smoosh against seven other shells that aim for some measure of POSIX compliance (bash, dash, zsh, OSH, mksh, ksh93, and yash). Using three test suites-the POSIX test suite, the Modernish test suite and shell diagnosis, and a test suite of our own device-we found Smoosh's semantics to be the most conformant to the POSIX standard. Modernish judges Smoosh to have the fewest bugs (just one, from using dash's parser) and no quirks. To show that our semantics is useful beyond yielding a conformant, executable shell, we also implemented a symbolic stepper to illuminate the subtle behavior of the shell.
Smoosh will serve as a foundation for formal study of the POSIX shell, supporting research on and development of new shells, new tooling for shells, and new shell designs.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 45afa7ea-83c9-4159-8196-08e2564783d9Cited by top-tier papers6
- Petr4: formal foundations for p4 data planesRyan Doenges, Mina Tahmasbi Arashloo, Santiago Bautista, Alexander Chang et al.POPL 2021 · 24 citations
- The Koala Benchmarks for the Shell: Characterization and ImplicationsEvangelos Lamprou, Ethan Williams, Georgios Kaoukis, Zhuoxuan Zhang et al.USENIX ATC 2025 · 12 citations
- Fractal: Fault-Tolerant Shell-Script DistributionZhicheng Huang, Ramiz Dundar, Yizheng Xie, Konstantinos Kallas et al.NSDI 2026 · 4 citations
- hS: Speculative Script Reordering at Subprocess GranularityGeorgios Liargkovas, Di Jin, Tianyu (Ezri) Zhu, Dan Liu et al.OSDI 2026 · 3 citations
- Feature-Sensitive Coverage for Conformance Testing of Programming Language ImplementationsJihyeok Park, Dongjun Youn, Kanguk Lee, Sukyoung RyuPLDI 2023 · 3 citations
Related papers
- PaSh: light-touch data-parallel shell processingNikos Vasilakis, Konstantinos Kallas, Konstantinos Mamouras, Achilles Benetopoulos et al.EuroSys 2021 · 12 citations
- Practically Correct, Just-in-Time Shell Script ParallelizationKonstantinos Kallas, Tammam Mustafa, Jan Bielak, Dimitris Karnikis et al.OSDI 2022 · 13 citations
- Ahead-of-Time Analysis of Shell Program EffectsLukas Lazarek, Evangelos Lamprou, George Kapetanakis, Anirudh Narsipur et al.SOSP 2026
- DiSh: Dynamic Shell-Script DistributionTammam Mustafa, Konstantinos Kallas, Pratyush Das, Nikos VasilakisNSDI 2023 · 11 citations
- POSH: A Data-Aware ShellDeepti Raghavan, Sadjad Fouladi, Philip Alexander Levis, Matei ZahariaUSENIX ATC 2020 · 33 citations
