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 builtins::sched;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 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 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 vm_helper::ShellExecutor;pub use zshrs_daemon as daemon;pub use ported::*;
Modules§
- aot
aotsubmodule. Ahead-of-time build: bake one or more shell scripts into a copy of the runningzshrsbinary 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 arith_compilersubmodule. ArithCompiler — lowers zsh arithmetic expressions ($((...))) into fusevm bytecodes. Used byZshCompiler(incompile_zsh.rs).- ast_
sexp ast_sexpsubmodule. Canonical AST s-expression emitter forZshProgram.- autoload_
cache autoload_cachesubmodule. rkyv-backed bytecode cache for autoload functions.- bash_
complete bash_completesubmodule. Rust-original types for the bash-stylecompletebuiltin extension.- canonical_
apply canonical_applysubmodule. Apply daemon canonical state to a freshly-built ShellExecutor — by reading the daemon’s rkyv shard directly from disk. No IPC.- compile_
zsh compile_zshsubmodule. Bytecode compiler for the portedZshProgramAST.- compinit_
bg compinit_bgsubmodule. Background compinit pre-warm — extension; no zsh C counterpart.- completion
completionsubmodule. SQLite-backed completion engine (legacy / unused).- compsys
compsyssubmodule. Zsh-compatible completion system (compsys)- config
configsubmodule. zshrs configuration file —~/.config/zshrs/config.toml.- daemon_
presence daemon_presencesubmodule. Daemon-presence detection + per-user config knob.- dap
dapsubmodule. DAP server for zshrs —zshrs --dap HOST:PORT.- dumpers
dumperssubmodule. Source-to-IR dumpers exposed to thezshrsCLI 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_
jobs exec_jobssubmodule. Executor-side bg-job tracker. NOT a port ofSrc/jobs.c.- ext_
builtins ext_builtinssubmodule. Extension-only shell builtins (no zsh C counterpart).- extensions
extensionssubmodule. zshrs extensions — features zsh C does not have.- fds
fdssubmodule. File descriptor utilities for zshrs.- fish_
features fish_featuressubmodule. Fish-style features for zshrs - native Rust implementations.- func_
body_ fmt func_body_fmtsubmodule. Non-C helper: format raw function-body source the way zshtypeset -fpresents multi-statement bodies (split on top-level;/ newlines).- fusevm_
bridge fusevm_bridgesubmodule. fusevm bytecode-VM bridge for ShellExecutor.- fusevm_
disasm fusevm_disasmsubmodule. Optional fusevm bytecode listing to stdout whenzshrsis invoked with--disasm.- gen_
docs gen_docssubmodule. Module-doc generator — produces Markdown documentation from a parsed zshrs source file by pairing##doc comments with the top-level function declaration immediately below them.- heredoc_
ast heredoc_astsubmodule. Heredoc AST-glue types — Rust-only, NOT in zsh C.- history
historysubmodule. SQLite-backed command history for zshrs.- intercepts
interceptssubmodule. Command intercept / advice machinery — extension; no zsh C counterpart.- log
logsubmodule. zshrs logging & profiling framework.- lsp
lspsubmodule. LSP server for zshrs —zshrs --lsp.- lsp_
symbols lsp_symbolssubmodule. AST-walked symbol table for the zshrs LSP server. Powers cross-file rename and find-references with parser-validated scoping instead of the textual occurrence scan incrate::extensions::lsp::references.- overlay_
snapshot overlay_snapshotsubmodule. Shell-side overlay enumeration forzsync up --all.- plugin_
cache plugin_cachesubmodule. Plugin source cache — stores side effects ofsource/.in SQLite.- ported
portedsubmodule. Ported subsystems — every submodule here is a faithful 1:1 port of a corresponding upstream zsh C source file undersrc/zsh/Src/.- regex_
mod regex_modsubmodule. Regex module - port of Modules/regex.c- script_
cache script_cachesubmodule. rkyv-backed bytecode cache for zsh scripts.- stringsort
stringsortsubmodule. String manipulation and sorting for zshrs- vm_
helper vm_helpersubmodule. Shell executor state for zshrs.- worker
workersubmodule. Worker pool for zshrs — persistent threads for background work.- zsh_ast
zsh_astsubmodule. Zsh AST types — Rust-only, NOT in zsh C.- zsh_
builtin_ docs zsh_builtin_docssubmodule.- zsh_
ext_ builtin_ docs zsh_ext_builtin_docssubmodule.- zsh_
keyword_ docs zsh_keyword_docssubmodule.- zsh_
option_ docs zsh_option_docssubmodule.- zsh_
special_ var_ docs zsh_special_var_docssubmodule.- ztest
ztestsubmodule — shell-level unit test framework (port of../strykelangtest framework).ztest— shell-level unit test framework.- zwc
zwcsubmodule. ZWC (Zsh Word Code) file parser. Direct port of the dump-file family in zsh/Src/parse.c:3077-end.- zwc_
decode zwc_decodesubmodule. 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§
- DPUTS
- Port of
#define DPUTS(X, Y)macro fromSrc/zsh.h:2918(macro). - DPUTS1
- Port of
#define DPUTS1(X, Y, Z1)macro fromSrc/zsh.h:2919(macro). - DPUTS2
- Port of
#define DPUTS2(X, Y, Z1, Z2)macro fromSrc/zsh.h:2920(macro). - DPUTS3
- Port of
#define DPUTS3(X, Y, Z1, Z2, Z3)macro fromSrc/zsh.h:2921(macro). - 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.
Statics§
- IS_
ZSH_ MODE - Runtime shell-mode flag set by the binary entrypoint (
bins/zshrs.rs) at startup. The library can’t directly readbins/zshrs.rs::shell_mode()(it lives in the binary crate), so the binary writes this atomic when parsing--zsh/--bash/--posixand the library reads it from bridge / dispatch sites that need to gate bash-compat-vs-zsh behavior. Defaults tofalse(zshrs-native mode) when not explicitly set.
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.