Idea · Oct 12, 2026
Expansion Order
Paste a shell command line and step through exactly what Bash does to it: brace, tilde, parameter, command substitution, arithmetic, word splitting, globbing and quote removal, one stage at a time, ending with the argv the program really receives.
What it would do
A recent HN thread showed how a quoted tilde in PATH silently leaves a literal '~' in the variable, and the comments proved that even experienced users disagree about when tilde expansion happens. Expansion Order makes the POSIX/Bash word-expansion pipeline visible. The user pastes a line (with an editable fake environment: HOME, PATH, IFS, a mock directory tree for globbing) and the tool tokenizes it, then shows each expansion stage as a separate row, highlighting which words changed and which quotes protected them. The final row is the argv array, so the classic bugs (unquoted variables splitting on spaces, globs matching nothing, tilde after a colon in assignments, $@ vs $*) become concrete. A 'predict the argv' quiz mode, and a cross-check that runs the same line in a real bash -c with printf '%s\n' for verification during development, keep it honest.
Key features
- Stage-by-stage expansion table from raw tokens to final argv, with changed words highlighted
- Editable mock environment: variables, IFS, and a fake file tree for glob matching
- Assignment-context rules (tilde after ':' in PATH=...) shown separately from command-word rules
- Curated gallery of real footguns: quoted tilde in PATH, unquoted $var with spaces, rm $dir/*, "$@" vs $*
- Predict-the-argv quiz with shareable URL-encoded challenges