Compatibility #
Authority #
The Plan 9 rc manual defines the target language.
The Plan 9 port source resolves pattern behavior and other ambiguities.
The suite compares plan9port rc and Rakitzis rc.
The adjacent ../rc repository supplies Rakitzis rc. Its behavior does not override the Plan 9 language.
Examples of deliberate differences from the Unix reference:
*includes hidden files, except.and...- A nonempty list cannot concatenate with an empty list.
[~class]complements a character class.!has no special class meaning.- Backslash does not escape ordinary characters.
- A successful command stores an empty string in
$status. -sprints failed command status. It does not select standard input.- A false
ifretains its condition's status. The Unix reference returns success when it skips the body. - Pattern matches use Unicode code points, not bytes.
- A quoted join of an empty list supplies one empty word.
- Subscripts consume decimal prefixes and skip selectors that name no elements.
shiftconsumes a signed decimal prefix. A nonnumeric count means zero, and an excessive count drains the list.- Here-documents use variable values from the input boundary, before assignments on the same command line.
Here-documents in functions work. This removes a documented limitation of the original shell. This extension retains execution-time expansion inside functions, including repeated calls and imported definitions.
POSIX adaptations #
Login mode reads $home/.rcrc, as Rakitzis rc does, instead of the Plan 9 path $home/lib/profile.
Non-login shells do not read this file automatically.
- External failures use numeric Unix status strings.
- Signal deaths use the conventional
128 + signalexit code. - Missing and nonexecutable commands use exit codes 127 and 126. Both references use exit code 1.
- An arbitrary nonempty status string maps to Unix failure at process exit.
$homeinitially usesHOMEwhen the environment lackshome.$pathinitially usesPATHwhen the environment lackspath.- Process substitution uses
/dev/fd. - The shell uses internal startup defaults instead of
/rc/lib/rcmain. -mselects an explicit initialization file.-nchecks syntax without execution, as a Unix compatibility extension.-pand-ddo nothing, as the Plan 9 manual specifies.- Pipelines store each numeric stage status, separated by
|. Successful stages contribute empty strings. Unlike plan9port, rc2 retains the position of the first successful stage. rfork eandrfork fpreserve the existing POSIX isolation.rfork screates a process group.Eclears exports, andFcloses the descriptor table.- Interrupts in
. -irecover at the nearest interactive source, including a source from process substitution. - Namespace flags
n,N, andmproduce an explicit error. The defaultrforkalso requires namespace support.
Function import accepts exactly one literal function definition with the expected name. The interpreter rejects extra commands and computed function names before execution. This restriction rejects command text outside the declared function body.
The interpreter rejects NUL bytes in source text and command substitution. Unix argument vectors cannot represent embedded NUL bytes.
Scope and limits #
The conformance matrix maps manual sections and UNIX extensions to regression coverage. Coverage does not establish complete compatibility for every input.
- The approved POSIX scope rejects Plan 9 namespace operations.
- The approved UNIX extensions include
whatis -s/-f/-v/-p/-band. -i file. Optional reference add-ons remain excluded. - Job control requires a controlling terminal.
jobs,fg, andbgare UNIX extensions, not Plan 9 commands. - Completion reads scalar variables but never executes input substitutions. Multivalue computed prefixes remain unsupported.
- Script declarations support recursive subcommands. Metadata extraction requires one top-level declaration block.
- Nesting limits reject syntax or execution deeper than 256 recursive levels.
- Terminal width depends on libc and the terminal's Unicode display conventions. Grapheme boundaries use Unicode 18 data.
- Runtime validation covers macOS arm64, Linux arm64, and Linux amd64 under Docker emulation. Other UNIX systems and architectures lack runtime validation.
The editor supports wrapped lines, resize, complete multiline history, and grapheme movement.
Persistent history uses the reference's opt-in $history convention, with owner-only regular files and locked appends.
Resource-limit reports use raw bytes, seconds, or counts, rather than formatted suffixes.
Default interactive termination uses normal cleanup. SIGKILL cannot permit terminal cleanup.
Text, syntax, and transient values use safe-point reclamation.
Active evaluations retain their pool prefixes. Live variables, functions, history, and status caches retain their referenced objects.
Large active source files and live shell state still determine peak memory use.
Background processes retain their status until wait consumes it.
Signal functions run during input, command substitution, and child waits, as well as evaluator boundaries. Signal functions defer other signal functions until the current function returns. Source-file reads preserve partial input across signal interruptions. Signal functions can source another file before the interrupted read resumes. Interactive source input temporarily handles default interrupts and quits. It restores caller dispositions but preserves explicit trap changes.
The Plan 9 compiler emits Xif without a status reset.
The executor skips a false body without changing $status.
The false-if difference therefore follows the Plan 9 target, not an omitted UNIX feature.
The test suite is a conformance corpus, not proof of complete compatibility. Performance results apply only to the measured workloads and host.
Conformance decisions #
Plan9port's subwords consumes decimal prefixes and omits empty or reversed selections.
Rc2 uses this behavior but bounds numbers to the list length instead of permitting integer overflow.
Plan9port's execshift uses atoi and stops after the argument list becomes empty.
Rc2 retains decimal-prefix conversion, including negative counts that drain the list. Nonnumeric and zero counts preserve the list.
Rc2 bounds counts to the list length, so large input cannot overflow.
Plan9port's readhere substitutes variables before it executes the parsed input.
Rc2 snapshots ordinary unquoted bodies at the complete-input boundary. Quoted bodies remain literal, and function bodies retain the extension above.
The Plan 9 manual explicitly specifies eval [arg ...], so an empty eval remains valid.
Plan9port's execeval incorrectly requires an argument. This discrepancy follows the manual instead of the implementation.
Tasks tsk-23 through tsk-26 record these decisions. CONFORMANCE.md records commands, counts, and reference identities.