paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Executable formal semantics for the POSIX shell

POSIX shell 的可执行形式语义
POPL 4(POPL)2019匹配度 3/10 · 论文为 POSIX shell 提供可执行形式语义,属于程序语言形式化方向,与用户核心关注的 LLM/Agent 静态分析、浮点程序分析、贝叶斯程序分析无直接交集;仅在 Agentic 程序可能涉及 shell 脚本分析时有一点间接关联。引用 21 inbox
Michael Greenberg, Austin J. Blatt
crossref: 2026-09-10

AI 速览

一句话:为 POSIX shell 定义可执行、机器化的小步操作语义 Smoosh,并通过测试验证其最符合 POSIX 标准。

POSIX shell 是管理系统的关键基础设施,功能强大但语义复杂微妙,长期缺乏精确形式化定义。本文为 POSIX shell 定义了机器化、可执行的小步操作语义 Smoosh,并实现对应解释器与符号步进器,以揭示其不直观行为。作者将 Smoosh 与 bash、dash、zsh、OSH、mksh、ksh93、yash 七种追求 POSIX 兼容的 shell 比较,使用 POSIX 测试套件、Modernish 测试套件与自建测试套件进行评估。结果显示 Smoosh 的语义最符合 POSIX 标准:Modernish 判定其 bug 最少(仅一个,来自 dash 解析器)且无怪癖。该工作为 POSIX shell 的形式研究、新 shell 与新工具开发提供基础。

问题
POSIX shell 广泛部署且属于关键基础设施,但其语义复杂、微妙且缺乏形式化定义,容易导致实现差异与误解。
方法
定义机器化、可执行的小步操作语义 Smoosh,并实现符号步进器以展示 shell 的微妙行为。
评估
使用 POSIX 测试套件、Modernish 测试套件与自建测试套件,将 Smoosh 与 bash、dash、zsh、OSH、mksh、ksh93、yash 七种 shell 比较;Smoosh 最符合 POSIX 标准,Modernish 判定其 bug 最少且无怪癖。
原文摘要(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 diagnostic, 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.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot525,
  title = {Executable formal semantics for the POSIX shell},
  author = {Michael Greenberg and Austin J. Blatt},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {4},
  number = {POPL},
  year = {2019},
  doi = {10.1145/3371111}
}