xsh is a fast and modular POSIX-like Unix shell written in modern C (C23 standard).
- C23 conforming compiler (gcc 14+ or clang 18+)
- Meson build system (1.3.0+)
- Ninja build tool
- GNU Readline
- GNU gettext (for translations)
meson setup build
ninja -C buildmeson test -C build --verboseninja -C build installxsh loads configuration from ~/.xshrc upon startup.
Build-time options can be configured via meson configure:
meson setup build -Ddefault_histsize=2000 -Ddefault_completion_drivers="native,fish,bash,zsh"xsh is structured into modular components:
- Lexer: Tokenizer with streaming support, line continuation checks, and quoting awareness.
- Parser: Recursive-descent parser producing an Abstract Syntax Tree (AST) supporting pipes, logical operators, redirection chains, subshells, command groups, if/elif/else branching, while/until/for loops, case pattern matching, and function definitions.
- Line Editor: Readline integration with prompt formatting, multiline inputs, and completion hook dispatching.
- Completion Engine: Pluggable framework with native xsh completions, fish completions, bash completions, and zsh completions.
- Job Control: Process group management, foreground/background pipeline handling, and job status notifications.
- Builtins: Core POSIX and interactive utilities.
- Variables and Expansions: Parameter expansion, command substitution, arithmetic expansion, and wildcard pathname expansion.
- Basic command execution and argument parsing
- Input and output redirections (
<,>,>>,2>,2>>,&>,&>>,2>&1,1>&2,<<) - Pipeline execution (
|) - Logical chaining (
&&,||,;,&) - Subshells and command grouping (
(...),{ ...; }) - Conditional execution (
if,then,elif,else,fi) - Loops (
while,until,for) - Functions and local scope
- Arithmetic expansion (
$((...))) - Command substitution (
$(...),`...`) - Process substitution (
<(...),>(...)) - Brace expansion (
{a,b,c},{1..10},{01..05},{a..z..2}) - ANSI-C quoting (
$'...') - Indexed arrays (
arr=(...),${arr[i]},${arr[@]},${arr[*]},${#arr[@]},${!arr[@]}) - Parameter expansion (
$VAR,${VAR}) - Wildcard pattern matching (globbing)
- Signal handling and job control (
jobs,fg,bg,disown) - Core builtins (
cd,pwd,echo,printf,times,export,unset,exit,test,[,[[,break,continue,return,history,bind,source,.,builtins,help) - Interactive line editing with GNU Readline
- History persistence and limit controls
- Configurable prompt strings (
PS1) - Command line hooks (
precmd,chpwd,PROMPT_COMMAND) - Modular completion architecture
- Native xsh completion format (
completebuiltin) - Fish completion format support
- Bash completion format support
- Zsh completion format support
- Configurable completion drivers and fallback paths in ~/.xshrc
- Native xsh completion format (
- POSIX Compatibility
- Pattern matching and branching (
case ... in ... esac) - Parameter expansions (
${#var},${var#pattern},${var##pattern},${var%pattern},${var%%pattern},${var:=default},${var:+alt},${var:?err}) - Process and signal control (
trap,kill,wait,exec,eval) - Input and parameter builtins (
read,shift,getopts,umask,printf,times) - Shell introspection and modes (
type,command,alias,unalias,set -e,set -u,set -x,set -f) - Resource limits builtin (
ulimit)
- Pattern matching and branching (
- Automated test suite (
meson test)- Basic commands, pipelines, and grouping tests
- Redirections and heredocs tests
- Control structures and pattern matching tests
- Arithmetic, parameter, and string expansions tests
- Brace expansion tests
- ANSI-C quoting tests
- Indexed arrays tests
- Shell functions, scoping, and recursion tests
- POSIX utilities, options, aliases, and types tests
- Process resource limits tests
- Command line hooks tests
- Localization and translation tests
- Project documentation and manual
- UNIX manual page (
doc/xsh.1) - User manual guide (
doc/manual.md) - Example configuration (
examples/xshrc)
- UNIX manual page (
- Internationalization and localization (i18n / l10n)
- GNU gettext integration via Meson
- Russian translation catalog (
po/ru.po)
GNU General Public License v3.0