roadmap BUILT

47. Navigation and naming: cd, pwd, ls, mkdir, rm, paths, and environment

Every item is Done, refused or routed to a numbered milestone, so the block is BUILT. The set grant at the prompt follows §228 (how a set of matched names reaches the progenitor), built by milestone 205 (how a foreign program is told what to do). The detail of each piece is in 0047-navigation-and-naming/; this page is complete without it.

Piece Where it stands Appendix
mkdir, rm, RMDIR and rm -r built, §49 (removal is a directory operation) mkdir-and-rm.md
ln none: hard links declined by §110 (hard links are declined), symlinks replaced by bind under §50 (namespace composition) links-and-bind.md
touch, both halves, and globbing with its set grant built, §112 (touch's two behaviors need two rights) touch-and-globbing.md
Absolute paths and bind built; bind in a two-grant shell host-tested only (milestone 154 (a process that holds two directory capabilities)) absolute-paths-and-bind.md
Environment: the config page of §111 (inert configuration is a read-only page), printenv, caps printenv built; secrets belong to milestone 65 (a secrets service) environment.md
PATH and completion built, §229 (how a bare name at the prompt reaches an installed program) B2 and §227 (how Tab reaches the shell) option D path-and-completion.md
file: and run removed; the function-call syntax refused by §141 (application is grant) shell-grammar.md

In brief. A navigation model for a system with no global namespace. Keep the Unix command names and behavior wherever they can work honestly; diverge only where the capability model forces it, and say why each divergence is earned. The keystone is built: the directory capability and its rights ladder (DECISIONS §47 (the directory capability's rights), notes/dir-capability.md), six rungs at the keystone and a seventh added by DECISIONS §112 for touch -t. So are the five commands, on both ISAs. cd, pwd, ls, mkdir and rm work as shell builtins. .. is clamped at your root by popping the stack of capabilities the shell descended through, and pwd is relative to that root. A name on a command line is resolved against the shell's position at the moment the grant is made, so a child holds a capability to one file and cannot re-resolve anything. The headline is proven with the real shell binary: two shells rooted in two subtrees, each told nothing about which it holds, and neither can name the other's files (notes/shell-navigation.md).

Why it matters. calef's framing, and it is the governing constraint for the shell's commands: "I hate Windows/DOS specifically because they went differently than virtually every other OS I've used." Gratuitous divergence taxes every user forever. So the bar is not "is this more capability-pure", it is "does the model actually force this." Three divergences clear that bar; the rest of Unix's commands should survive unchanged.

That rule governs commands. The language around them (grouping, scoping, substitution, testing) follows §312 (swish has one way to do each job) instead: |, the redirections, &&, || and $( ) stay as Unix spells them, and every other job has one form. notes/swish-language.md carries the language.

The reframe: cd was never the problem

A working directory, in capability terms, is a directory capability the shell holds, used as the default base for resolving names. Held by the shell that is entirely legitimate, the same as its untyped budget. The badness in Unix is three specific things, none of which is cd itself:

  1. Children inherit it silently, so every process gets a starting point nobody granted it.
  2. Relative paths resolve implicitly, so a program's reach depends on invisible state.
  3. .. walks out, so the cwd bounds nothing.

Fix those three and the command is fine.

cd, pwd, ls are shell builtins, not programs

The same category as caps, which already prints the shell's whole endowment: they spawn nothing, need no grant, and confer no new authority, because the shell is reading and rebinding what it already holds. So no listing program is over-granted with the power to read everything it lists: ls is not a program.

The cwd stops at the process boundary. wc report.txt resolves the name against the shell's current directory at the moment the grant is made, and the child receives a capability to that one file. The child has no cwd, inherits nothing, and cannot re-resolve anything. The convenience is the shell's; the authority is explicit.

The earned divergences

Absolute paths are not a divergence: / is the root of your own namespace, Plan 9's answer (absolute-paths-and-bind.md). The InvalidFilename refusal survives for the two cases that still name nothing, .. past the root and a Windows-shaped prefix.

What that buys, and Unix cannot: every shell has its own root. Two shells can hold different subtrees and neither can name the other's files, not by policy but because no capability reaching them exists.

The primitive underneath

cd, mkdir, and per-process namespaces each converge on the same primitive: a verb that returns a directory capability rather than bytes. It is the first place this contract hands back authority instead of data. It deserves the care Endpoint::REAP got under §32 (a supervisor may collect a corpse without being able to build one). What rights does the child directory carry, can they ever exceed the parent's, and who may call it?

Follow-on

Index row

divergence from Unix must be earned, never stylistic. Keep the commands; change only what the capability model actually forces, and get one missing primitive right