POSIX shell written in Zig
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-28 14:58:14 -04:00
src arithmetic: read a variable's number and write a result with loops of our own rather than the formatted parse and print, and join an assignment's name and value by copying; an assignment such as n=$((n+1)) costs 13% less; a number with an underscore in it, which the parse let through, as in x=1_0, is now an error, as POSIX has it 2026-09-28 14:58:14 -04:00
.gitignore ignore tests/ 2026-08-30 14:23:16 -04:00
build.zig locale: in a UTF-8 locale, as LC_ALL, LC_CTYPE and LANG decide it and as they change, take a character to be its whole UTF-8 sequence for ${#x}, pattern matching (?, bracket expressions with character classes from the Unicode general category, * and prefix and suffix removal), field splitting and read on IFS characters, the joining of "$*" and the value printf gives 'c; in the C locale a character stays a byte (POSIX 2.5.3) 2026-09-28 11:08:51 -04:00
build.zig.zon the clock in a prompt: \t and \A on a 24-hour one, \T and \@ on a 12-hour one, \d for the date and \D{...} for any strftime, spelled as the reference prompt spells them so a PS1 written for that one keeps working — the zone comes from /etc/localtime or $TZ read the way everything else reads it, by name or by path with the colon optional and a POSIX rule string only when neither is a file, and it is parsed once and kept rather than per prompt 2026-08-31 20:38:39 -04:00
LICENSE Initial commit 2025-01-23 15:40:33 -05:00
README.md export, unset, and NAME=value assignments 2026-08-27 17:13:20 -04:00

wsh

Wizard Shell

This is a passion project to learn how POSIX shells work. This is my first real project at least that I plan to finish (let's see how that goes). The objective is to eventually get this to be daily driveable and fully POSIX compliant.

Build

Requires a recent Zig master (0.17.0-dev).

zig build -Doptimize=ReleaseFast -Dstrip

Supports:

  • Quoting ("wizard's spellbook", wizard\'s academy) [backticks not supported yet]
  • autocomplete (absolute and relative)
  • pipes
  • >, 1>, 2>, and the >> equivalents
  • < input redirection and << heredocs
  • fd duplication (2>&1, >&2) and &>/>& (redirect both)
  • && and || command chaining, ; separators
  • & background jobs
  • home directory paths (~)
  • builtins supported (so far): echo, cd, exit, pwd, type
  • backspace and delete
  • left and right arrow key scrolling
  • default? set enviornment variables ($TERM)
  • reverse search on shell history
  • completion menu
  • ctrl-r history search
  • bang commands

TODO/wish list:

  • echo enviornment variables
  • remaining POSIX operators (<&, <>, arbitrary fds like 3>, ! negation)
  • job control (jobs, fg, bg)
  • all POSIX builtins (export, alias, shopt, etc.)
  • shell scripts
  • rc file
  • vi mode
  • base16 and 256 custom color prompts