shlex

Split a string into POSIX shell words, like Python's shlex module

Library
Cargo
v2.0.1
159 stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
37 /100 Needs Attention
Development Activity 12
Maintenance 0
Community 56
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
70 /100 Good
Architecture 70
Code Quality 74
Innovation 58
Learning Curve 78

shlex is a small, dependency-free Rust crate that splits a string into shell-style words following POSIX shell tokenization rules, similar to Python’s shlex.split. It handles quoting and escaping the way a POSIX shell would, without exposing the customization knobs of the Python module, keeping the implementation compact and fast.

The crate works on both native Rust strings and byte strings (via its bytes module), with an algorithm that is deliberately UTF-8-high-byte oblivious so it behaves correctly on non-UTF-8 input as well. Its huge download count (600M+ total) reflects its role as a low-level dependency inside many command-line and build-tooling crates.

What You Get

  • shlex::split to tokenize a string into shell words following POSIX rules
  • Quoting/escaping helpers to turn arbitrary strings back into shell-safe tokens
  • A bytes module offering the same operations over byte strings, for non-UTF-8-safe input
  • no_std-friendly design via the optional std feature flag
  • A fuzzed test suite (fuzz/) comparing behavior against Python’s shlex and real shell implementations

Common Use Cases

  • Parsing a user-supplied command string (e.g. a build flag or shell alias) into argv-style tokens
  • Splitting shell-style strings embedded in config files (Makefiles, .env-like files, compiler flag strings)
  • Quoting dynamically generated arguments before passing them into a subprocess invocation
  • Implementing REPLs or CLI tools that need shell-compatible tokenization without shelling out

Under The Hood

Architecture The crate is intentionally minimal: src/lib.rs (324 lines) implements the core string-based splitter and quoter, while src/bytes.rs (516 lines) duplicates the same logic for byte slices so callers working with non-UTF-8 input get identical tokenization semantics without a UTF-8 conversion step. A separate fuzz/ workspace holds multiple fuzz targets that cross-check the crate’s output against Python’s shlex and against real shell/wordexp behavior. Tech Stack Zero required dependencies, no_std-compatible via a std feature flag (enabled by default), targeting Rust edition 2018 with an MSRV of 1.46.0 — chosen deliberately low given the crate’s role as a widely-vendored transitive dependency. Code Quality Correctness is validated primarily through differential fuzzing (fuzz_quote_python, fuzz_quote_real_shell, fuzz_quote_wordexp, fuzz_next) rather than conventional unit tests alone, comparing shlex’s output against Python’s shlex module and actual POSIX shell/wordexp behavior to catch tokenization edge cases. API Design The public surface is deliberately narrow — a split function and quoting helpers, mirrored identically between str and bytes variants — trading the Python module’s configurability for a smaller, faster, easier-to-audit API that’s simple to vendor into performance- or size-sensitive tooling.

Used by 5 apps in this directory

Rust
86%
Other

Arroyo

Analytics · Data Engineering

5,039

A distributed stream processing engine written in Rust that lets you write SQL to run stateful, real-time computations over data streams with subsecond results.

View details
86
Repo Health
74
Technical
62
Dependency
Built with
Rust 86%
Updated 1 weeks ago
Rust
80%
MIT

fabro

Developer Tools · Devops

1,658

Define AI agent workflows as code graphs, route tasks across any LLM, and intervene only where it matters.

View details
82
Repo Health
83
Technical
67
Dependency
Built with
Rust 80%
TypeScript 15%
Updated 5 days ago
Rust
73%
Other

iii

Developer Tools · Devops

18,814

Compose, extend, and observe every backend service in real time using three primitives: Workers, Functions, and Triggers.

View details
87
Repo Health
85
Technical
65
Dependency
Built with
Rust 73%
TypeScript 16%
Updated 5 days ago
Rust
89%
Apache 2.0

OpenFang

AI Agents

18,210

An open-source "Agent Operating System" built in Rust — a single binary providing a kernel, memory, skills, extensions, and multi-channel runtime for running AI agents, with 1,700+ tests and zero clippy warnings.

View details
52
Repo Health
73
Technical
68
Dependency
Built with
Rust 89%
Updated 3 months ago
Rust
50%
Apache 2.0

Vibe Kanban

AI Agents · AI Code Assistants · Project Management

28,209

A kanban board for planning work and dispatching Claude Code, Codex, Gemini CLI, and eight other coding agents into isolated git worktrees, then reviewing and merging their diffs from one UI.

View details
75
Repo Health
75
Technical
64
Dependency
Built with
Rust 50%
TypeScript 46%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers