#shell #runtime

bin+lib conch-runtime

A library for evaluating/executing programs written in the shell programming language

7 releases

Uses old Rust 2015

0.1.6 Jun 3, 2019
0.1.5 Sep 22, 2018
0.1.4 Jan 27, 2018
0.1.1 Sep 14, 2017
0.0.0 Dec 5, 2016

#194 in Asynchronous

30 downloads per month


12K SLoC


Crates.io Documentation Build Status Build Status Coverage

A Rust library/runtime for executing Unix shell commands.

Quick Start

First, add this to your Cargo.toml:

conch-runtime = "0.1"

Next, you can get started with by looking at the barebones shell example.


This library offers executing already parsed shell commands as defined by the POSIX.1-2008 standard. This runtime attempts to remain agnostic to the specific Abstract Syntax Tree format a parser could produce, as well as agnostic to features supported by the OS to be as cross platform as possible.

Specifically implementations are provided for all the default AST nodes produced by the conch-parser crate. Unlike other Unix shells, this library supports Windows1 and can likely be extended for other operating systems as well.

1Major features are reasonably supported in Windows to the extent possible. Due to OS differences (e.g. async I/O models) and inherent implementation exepectations of the shell programming language, certain features may require additional runtime costs, or may be limited in nature (e.g. inheriting arbitrary numbered file descriptors [other than stdio] is difficult/impossible due to the way Windows addresses file handles).


  • Provide efficient, modularized implementations of executing parts of the shell programming language that can be used as a basis to build out other shell features
  • Execution implementations should be indepdendently reusable and agnostic to specific AST representations
  • Reasonable feature parity across operating systems to the extent possible
  • Avoid assumptions of particular implementation details and allow the caller to select appropriate tradeoffs to the extent possible


  • 100% POSIX.1-2008 compliance: the standard is used as a baseline for implementation and features may be further added (or dropped) based on what makes sense or is most useful
  • Feature parity with all major shells: unless a specific feature is widely used (and considered common) or another compelling reason exists for inclusion. However, this is not to say that the library will never support extensions for adding additional syntax features.
  • A full/complete shell implementation: this library aims to be a stepping stone to building out a complete shell without being one itself.

Supported features

  • Conditional lists (foo && bar || baz)
  • Pipelines (! foo | bar)
  • Jobs (foo &)
  • Compound commands
    • Brace blocks ({ foo; })
    • Subshells ($(foo))
    • for / case / if / while / until
  • Function declarations
  • Redirections
    • Heredocs
    • File descriptor inheritance for non-stdio descriptors
  • Expansions
    • Parameters ($foo, $@, etc.)
    • Parameter substitutions (${foo:-bar})
    • Glob/Path Expansions
    • Tilde expansions
    • Arithmetic substitutions
      • Common arithmetic operations required by the standard
      • Variable expansion
      • Other inner abitrary parameter/substitution expansion
  • Quoting (single, double, backticks, escaping)
  • Builtin commands (e.g. cd, echo, etc.)
  • Signal handling
  • Alias resolution


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~124K SLoC