Skip to content

v3.0.0 (Phoenix)

Latest

Choose a tag to compare

@Geekstrange Geekstrange released this 21 May 00:16
· 1 commit to main since this release
v3.0.0
daf0f94

Warning

dpshell is under active development with unstable features. It is NOT recommended to use it as the default login shell in production environments.

Caution

Security restrictions such as fork bomb prevention cannot provide full protection. Do not execute untrusted scripts or unknown commands in risky environments.

Important

Certain configuration options like bash_compat will load user profile scripts (~/.bashrc) automatically. Please ensure all sourced scripts come from trusted sources.

Note

dpshell does not source /etc/profile or ~/.bash_profile during login. If your workflow depends on login profile scripts, use bash or brush instead.


🧩 Parser

  • Recursive‑descent AST – added support for if/elif/else, for, while/until, case/esac, and function definitions as first‑class nodes
  • I/O redirection – >, >>, <, >&, <>, >|, <<, <<- with file descriptor tracking and adjacency detection
  • Command substitution prescan – preserves nested parentheses and quotes inside $(...)
  • Tokenizer split respecting $( – split_respecting_dollar_paren keeps $() content intact during shlex splitting
  • Deferred command resolution – unresolved commands at parse time are accepted, allowing runtime function dispatch
  • Compound commands – { ... } can be used as pipeline stages
  • Loop trailing redirections – while ... done <file is now correctly parsed
  • \$ escape handling – passed through expansion pipeline via U+FFFD sentinel

🔧 Variable Expansion

  • New expand_vars module – supports positional parameters $1…$9, $#, $@, $*
  • Parameter modifiers – ${var:-default}, ${var-word}, ${var:+word}, ${var+word}, ${var:=word}
  • Pattern stripping – ${var%pattern}, ${var%%pattern}, ${var#pattern}, ${var##pattern}
  • Arithmetic expansion – $((expr)) with +, -, *, /, %, comparisons and variable lookup
  • Command substitution preservation – $(cmd) content is not prematurely substituted
  • Glob matching – simple_glob_match provides fnmatch‑style patterns for case arms and ${var%pat}

⚙️ Executor

  • Command substitution – capture_subshell_output using fork/pipe/waitpid
  • In‑process pipelines – builtins and brace groups run inside the shell without forking
  • Runtime binary resolution – deferred command lookup now works for functions and external programs
  • Function call threading – ExecContext passes positional parameters correctly
  • Exit code propagation – $? (last_exit) is maintained across compound commands and lists
  • Bare variable assignments – VAR=value cmd handles command substitution in values
  • Loop redirection – while/until loops apply stdin redirection via dup2/restore
  • Pipeline output flush – stdout is flushed before process::exit to avoid data loss
  • Self‑binary detection – dynamic via current_exe() instead of hardcoded name

📦 Builtins

  • Modular registry – monolithic builtins.rs split into per‑command files with registry‑based dispatch
  • New recognized builtins – echo, read, printf, true, false
  • POSIX read – multi‑variable word splitting (splitn on IFS)
  • Builtin dispatch in executor – works correctly inside pipelines and functions
  • DpShell state – moved to shell/mod.rs with RefCell‑wrapped function table

📜 Script Mode

  • Non‑interactive execution – dpshell script.sh and dpshell -c 'cmd'
  • Multi‑line joining – detects unclosed blocks (if/for/while/case/function bodies)
  • Heredoc preprocessing – <<DELIM collects body and substitutes a temp file
  • Unified command routing – all script commands go through execute_node for proper expansion
  • Login shell profiles – sources /etc/profile, ~/.bash_profile, ~/.profile
  • Bash compatibility mode – additionally sources ~/.bashrc and uses ~/.bash_history

💻 REPL

  • Multi‑line input – heredoc collection and continuation detection
  • Dynamic config reload – /etc/deeprotection/config.toml is re‑read at each prompt
  • try_exit standalone – used for enforcing‑mode exit authentication

🏗️ Build & Code Health

  • New dependencies – clap, thiserror, itertools
  • Warning suppression – crossterm patch warnings via Cargo.toml lints and #[allow(dead_code)]
  • Cleanup – removed all unused imports and variables
  • Cargo config – renamed ~/.cargo/config → config.toml to silence deprecation warning
  • POSIX test suite – posix_test.sh validates 14 POSIX compatibility tests

🧬 Architecture Restructure

  • Flat src/*.rs → modules

    • builtins/ (27 files)
    • parser/ (3 files) – moved syntax.rs, expand_vars.rs
    • executor/ (2 files) – moved expand.rs
    • interactive/ (5 files) – moved bash_completer.rs, cycle_menu.rs
    • security/ (4 files) – moved rules.rs, plugins.rs, protection.rs
    • config/, jobs/, logging/, shell/
  • Renames and moves

    • ShellState → DpShell (now in shell::mod)
    • ExecContext gained shell_vars, last_exit, positional_params

💥 Breaking Changes

  • Module paths changed – all imports referencing top‑level modules (syntax, executor, rules, plugins, protection, builtins, logger) must update to their new nested paths
    • e.g. use syntax::... → use parser::syntax::...
    • use builtins::... → use builtins::registry::... (or specific builtin module)
  • ShellState renamed to DpShell and moved to shell::mod
  • ExecContext now requires additional fields (shell_vars, last_exit, positional_params) – any external code constructing it must adapt
  • Standalone binary detection no longer hardcodes the program name – may affect scripts that relied on argv[0] being unchanged