Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.
Eric Idogun edited this page Mar 24, 2025 · 3 revisions

๐Ÿš Crash Shell Wiki

Welcome to the Crash Shell Wiki โ€” a detailed guide to understanding, using, and extending your Rust-based modular shell. This is your go-to documentation for development, architecture, feature behavior, and contribution.


๐Ÿ“˜ Overview

Crash Shell is a minimalist Unix-like shell written in Rust. It supports command execution, built-in commands like cd, pwd, and export, and offers an interactive prompt with command history via rustyline.


๐Ÿงฑ Architecture

Crash Shell follows a clean, modular structure:

src/
โ”œโ”€โ”€ shell/
โ”‚   โ”œโ”€โ”€ mod.rs         # Shell runner and coordinator
โ”‚   โ”œโ”€โ”€ builtins.rs    # Built-in command logic
โ”‚   โ”œโ”€โ”€ interface.rs   # User prompt + command history (rustyline)
โ”‚   โ””โ”€โ”€ state.rs       # Shell state (cwd, previous dir, env)
โ”œโ”€โ”€ command/
โ”‚   โ”œโ”€โ”€ parser.rs      # Tokenizes and interprets input
โ”‚   โ””โ”€โ”€ executor.rs    # Runs external commands via std::process
โ”œโ”€โ”€ utils.rs           # Variable and tilde expansion
โ”œโ”€โ”€ main.rs            # Entry point

โš™๏ธ Built-in Commands

Crash Shell includes essential built-ins handled directly in builtins.rs:

Command Description
cd [path] Change current directory
cd - Switch to previous directory
pwd Print current working directory
export VAR=value Set environment variable in the current shell
exit Exit the shell

๐Ÿ’ก Environment Variable Expansion

Crash Shell supports:

  • ~ expansion to home directory
  • $VAR and ${VAR} lookup via std::env
  • export VAR=value to define runtime env vars

Expansion happens in utils.rs and is automatically applied to arguments during parsing.


๐Ÿง  Command History

  • Powered by rustyline
  • Arrow key navigation for history (โ†‘/โ†“)
  • History saved to .crash_history
  • Prompt is built dynamically using the current working directory

๐Ÿ”ฎ Planned Features

Feature ideas under consideration or development:

Feature Description
alias Define shortcut names for command strings
Redirection Handle >, >>, < for file IO
Piping Connect commands with `
Background Jobs Run commands with &
Config File Support ~/.crashrc to load aliases/env on start
Tab Completion Autocomplete commands, paths, variables

๐Ÿ›  Development Notes

  • You can run the shell with cargo run
  • The main input loop is in shell/mod.rs
  • Built-ins are matched by name in builtins.rs
  • Any unrecognized command is passed to the system via executor.rs

๐Ÿ“š How to Add a New Built-in

  1. Open shell/builtins.rs
  2. Add a new match arm in handle_builtin():
"mycommand" => {
    // your logic here
    true
}
  1. Update the README and wiki (here) if it's user-facing.

Happy hacking! ๐Ÿš๐Ÿš€