Expand description
Zsh interpreter and parser in Rust
This crate provides:
- A complete zsh lexer (
lexermodule) - A zsh parser (
parsermodule) - Shell execution engine (
execmodule) - Job control (
jobsmodule) - History management (
historymodule) - ZLE (Zsh Line Editor) support (
zlemodule) - ZWC (compiled zsh) support (
zwcmodule) - Fish-style features (
fish_featuresmodule) - Mathematical expression evaluation (
mathmodule)
Re-exports§
pub use ported::lex;pub use ported::lex as tokens;pub use ported::parse;pub use modules::attr;pub use modules::cap;pub use modules::clone;pub use modules::curses;pub use modules::datetime;pub use modules::db_gdbm;pub use modules::example;pub use modules::files;pub use modules::hlgroup;pub use modules::ksh93;pub use modules::langinfo;pub use modules::mapfile;pub use modules::mathfunc;pub use modules::nearcolor;pub use modules::newuser;pub use modules::param_private;pub use modules::parameter;pub use modules::pcre;pub use modules::random;pub use modules::random_real;pub use modules::regex as regex_module;pub use builtins::sched;pub use modules::socket;pub use modules::stat;pub use modules::system;pub use modules::tcp;pub use modules::termcap;pub use modules::terminfo;pub use modules::watch;pub use modules::zftp;pub use modules::zprof;pub use modules::zpty;pub use modules::zselect;pub use modules::zutil;pub use builtins::rlimits;pub use exec::ShellExecutor;pub use fish_features::autosuggest_from_history;pub use fish_features::colorize_line;pub use fish_features::expand_abbreviation;pub use fish_features::highlight_shell;pub use fish_features::is_private_mode;pub use fish_features::kill_add;pub use fish_features::kill_replace;pub use fish_features::kill_yank;pub use fish_features::kill_yank_rotate;pub use fish_features::set_private_mode;pub use fish_features::validate_autosuggestion;pub use fish_features::validate_command;pub use fish_features::with_abbrs;pub use fish_features::with_abbrs_mut;pub use fish_features::AbbrPosition;pub use fish_features::Abbreviation;pub use fish_features::AbbreviationSet;pub use fish_features::Autosuggestion;pub use fish_features::HighlightRole;pub use fish_features::HighlightSpec;pub use fish_features::KillRing;pub use fish_features::ValidationStatus;pub use tokens::lextok;pub use zshrs_daemon as daemon;pub use ported::*;
Modules§
- aot
- Ahead-of-time build: bake one or more shell scripts into a copy of the
running
zshrsbinary as a compressed trailer, producing a self-contained executable. At startup, zshrs detects the trailer and runs every embedded script IN INPUT ORDER as a single concatenated zsh program. - arith_
compiler - ArithCompiler — lowers zsh arithmetic expressions
(
$((...))) into fusevm bytecodes. Used byZshCompiler(incompile_zsh.rs). - ast_
sexp - Canonical AST s-expression emitter for
ZshProgram. - autoload_
cache - rkyv-backed bytecode cache for autoload functions.
- bash_
complete - Rust-original types for the bash-style
completebuiltin extension. - canonical_
apply - Apply daemon canonical state to a freshly-built ShellExecutor — by reading the daemon’s rkyv shard directly from disk. No IPC.
- compile_
zsh - Bytecode compiler for the ported
ZshProgramAST. - compinit_
bg - Background compinit pre-warm — extension; no zsh C counterpart.
- completion
- SQLite-backed completion engine for zshrs
- config
- zshrs configuration file —
~/.config/zshrs/config.toml. - daemon_
presence - Daemon-presence detection + per-user config knob.
- dap
- DAP server for zshrs —
zshrs --dap HOST:PORT. - dumpers
- Source-to-IR dumpers exposed to the
zshrsCLI as--dump-tokens,--dump-ast,--dump-wordcode. Same logic asexamples/{lex,ast,parse}_dump.rsand the parity harnesses (tests/lexer_parity.rs,tests/parity_harness.rs,tests/wordcode_parity.rs) — keeping them in one library function per IR so the binary, examples, and tests can all share output format. - exec
- Shell executor state for zshrs.
- exec_
jobs - Executor-side bg-job tracker. NOT a port of
Src/jobs.c. - ext_
builtins - Extension-only shell builtins (no zsh C counterpart).
- extensions
- zshrs extensions — features zsh C does not have.
- fds
- File descriptor utilities for zshrs.
- fish_
features - Fish-style features for zshrs - native Rust implementations.
- func_
body_ fmt - Non-C helper: format raw function-body source the way zsh
typeset -fpresents multi-statement bodies (split on top-level;/ newlines). - fusevm_
bridge - fusevm bytecode-VM bridge for ShellExecutor.
- fusevm_
disasm - Optional fusevm bytecode listing to stdout when
zshrsis invoked with--disasm. - heredoc_
ast - Heredoc AST-glue types — Rust-only, NOT in zsh C.
- history
- SQLite-backed command history for zshrs.
- intercepts
- Command intercept / advice machinery — extension; no zsh C counterpart.
- log
- zshrs logging & profiling framework.
- lsp
- LSP server for zshrs —
zshrs --lsp. - overlay_
snapshot - Shell-side overlay enumeration for
zsync up --all. - plugin_
cache - Plugin source cache — stores side effects of
source/.in SQLite. - ported
- Ported subsystems — every submodule here is a faithful 1:1 port of
a corresponding upstream zsh C source file under
src/zsh/Src/. - regex_
mod - Regex module - port of Modules/regex.c
- script_
cache - rkyv-backed bytecode cache for zsh scripts.
- stringsort
- String manipulation and sorting for zshrs
- worker
- Worker pool for zshrs — persistent threads for background work.
- zsh_ast
- Zsh AST types — Rust-only, NOT in zsh C.
- zwc
- ZWC (Zsh Word Code) file parser. Direct port of the dump-file family in zsh/Src/parse.c:3077-end.
- zwc_
decode - Recursive wordcode walker — decodes a
.zwcblob into the parser’s ownZshProgramAST so the parity harness can compare zsh-side and zshrs-side ASTs through a single sexp emitter (ast_sexp).
Macros§
- ERRMSG
- Port of
#define ERRMSG(x)fromSrc/zsh.h:2917. Build a debug error-message prefix__FILE__ ":" __LINE__ ": " x. - HEAP_
ERROR - Port of
#define HEAP_ERROR(heap_id)fromSrc/zsh.h:2864. Debug- only macro that fprintf’s an “invalid heap” error to stderr. Rust port: eprintln! with the same format. Only active under thezsh-heap-debugfeature. - STRINGIFY
- Port of
#define STRINGIFY(x)fromSrc/zsh.h:2916. Two-pass stringification (expand x first, then stringify). - STRINGIFY_
LITERAL - Port of
#define STRINGIFY_LITERAL(x)fromSrc/zsh.h:2915. C uses the#operator to stringify an identifier. Rust’sstringify!macro does the same.
Functions§
- set_
stryke_ handler - Register a handler for @ prefix lines (fat binary sets this to stryke::run).
- try_
stryke_ dispatch - Try to dispatch a line starting with @ to stryke. Returns Some(exit_code) if handled, None if no handler registered.