This commit is contained in:
Raven Scott
2026-04-03 17:56:46 -04:00
parent a7e08e093c
commit ec236f9cc7
28 changed files with 1052 additions and 97 deletions
+2 -1
View File
@@ -81,7 +81,8 @@ There is no arbitrary command execution, **`source`**, or control flow — it is
- **`registerBareService({ name, start })`**
- **`startBareInitd(ctx)`** — sequential start, per-service `try/catch`, `[bare-initd] name: err` on failure
- **`registerBareInitdDisposer(fn)`** + **`stopBareInitd()`** — for intervals and teardown
- **`registerKernelShutdownHook(fn)`** + **`runKernelShutdownHooks()`** — async-friendly teardown before disposers (REPL **`session.cleanup`** awaits hooks, then **`stopBareInitd()`**)
- **`registerBareInitdDisposer(fn)`** + **`stopBareInitd()`** — for intervals and synchronous teardown
Built-in **`kernel-logger`** wraps **`ctx.console.log` / `error`** to also append UTF-8 lines to **`$HOME/.kernel/kernel.log`** (creates **`~/.kernel/.keep`** best-effort). Failures to write logs are swallowed so logging never kills the session.
+2 -1
View File
@@ -71,7 +71,8 @@ Hyperdrive entries carry optional **`metadata.bareOs`** (mode, uid, gid, names,
| `sed`, `awk` | Large JavaScript engines in **`lib/*-engine.js`** — not byte-identical to GNU/POSIX everywhere; see ch. 9 |
| `tee`, `find`, `du`, `cksum` | Pipe tee, limited **`find`**, **`du -k`**, POSIX CRC **`cksum`** |
| `time`, `logname` | Wall-clock **`time`** via **`ctx.runBinCommand`**; identity string |
| `xargs`, `getconf`, `chown`, `chgrp`, `mkfifo` | Stubs with explicit “not supported” messages |
| `chown`, `chgrp`, `mkfifo` | Stubs with explicit “not supported” messages |
| `getconf`, `xargs` | Documented Bare subsets (fixed **`getconf`** table; bounded **`xargs`** via **`ctx.runBinCommand`**) |
| `pathchk` | Path sanity |
| `pwd` | Logical cwd |
| `rm` | Remove files; **`-r`/`-R`/`--recursive`** for directories, **`-f`/`--force`** (bundled **`-rf`**) — uses VFS tree walk + `del` per entry |
+18 -7
View File
@@ -10,12 +10,12 @@ Bare OS targets a **usable subset** of [POSIX.1-2017](https://pubs.opengroup.org
| Expectation (full POSIX) | Bare OS reality |
| ---------------------------------------------- | ------------------------------------------------------------------------------- |
| **`sh`** grammar (`if`, `for`, `&&`, `\|`, …) | Line-at-a-time shell: builtins + `/bin` only; no compound commands. |
| **`sh`** grammar (`if`, `for`, subshells, …) | Line-at-a-time shell: builtins + `/bin`; lists with **`;`**, **`&&`**, **`||`**, and **`\|`** pipelines—no **`if`/`for`**, groups, or full **`sh`** grammar. |
| **Processes, `fork`, pipes as OS primitives** | Pipelines are simulated by capturing **`console.log`** into the next command. |
| **`chown` / `chgrp` / real UIDs across users** | Single-session identity; metadata carries **uid/gid** for display and checks. |
| **FIFOs, `mknod`, real devices** | Not available; **`mkfifo`** is a documented stub. |
| **`xargs` spawning arbitrary programs** | Stub only — use the shell to build argument lists. |
| **`getconf` / `sysconf`** | Stub — no host kernel sysconf surface. |
| **`xargs`** full POSIX/GNU surface | Bounded implementation: **`ctx.runBinCommand`** only; **`-0`**, **`-n`** (and **`-nN`**); stdin/token/invocation caps (see **`src/xargs.js`**). |
| **`getconf` / live `sysconf`** | Fixed name table + **`-a`**; values are Bare constants, not host kernel queries (see **`src/getconf.js`**). |
| **Byte-identical `sed` / `awk` / `grep`** | JavaScript engines; regex and edge cases differ from GNU or strict POSIX. |
For the **`/bin` build contract** (no `import`, `AsyncFunction` load), see [Chapter 6](06-kernel-and-binaries.md).
@@ -51,7 +51,11 @@ There is **no** **`chown`** / **`chgrp`** that changes stored ownership in a mul
---
## 3. Shell builtins (`packages/bare-os-booter/lib/shell.js`)
## 3. Shell lists, pipelines, and builtins (`packages/bare-os-booter/lib/shell.js`)
**Top-level syntax:** the line is split on **`;`** into separate lists. Each list is an **AND-OR** chain: **pipelines** separated by **`&&`** or **`||`**, evaluated left-to-right with POSIX-style short-circuiting (**`ctx.exitCode`** — treat missing as **0**). Within a pipeline, **`|`** connects stages as before (simulated stdin between utilities).
**Unsupported:** lone **`&`** (background) is rejected with an error. There is no job control.
Beyond **`alias`**, **`unalias`**, **`cd`**, **`export`**, **`login`**, **`logout`**, **`exit`**:
@@ -113,17 +117,24 @@ Sources: **`packages/bare-os-coreutils/src/<name>.js`**. **Authoritative list:**
| **`logname`** | Prints **`LOGNAME`** / **`USER`** / **`guest`**. |
| **`time`** | Times **`ctx.runBinCommand`** for the rest of the line; prints **`real`** to stderr. |
### 5.4 Intentional stubs (fail with a clear message)
### 5.4 `getconf` and `xargs` (Bare subsets)
| Command | Behavior |
| ----------- | -------- |
| **`getconf`** | **`getconf NAME`** prints a value from a fixed table (**`PATH_MAX`**, **`_POSIX_VERSION`**, …). **`getconf -a`** prints all known names (each name then value on the following line). Unknown names exit **1**. |
| **`xargs`** | Reads **`bareStdin(ctx)`**; splits on whitespace or **`-0`** null bytes; runs **`await ctx.runBinCommand([utility, …initial, …batch])`** per batch. Flags: **`-0`/`--null`**, **`-n N`/`--max-args N`** (capped). Hard limits on stdin size, token count, args per run, and invocations per process—see **`src/xargs.js`**. |
### 5.5 Intentional stubs (fail with a clear message)
| Command | Reason |
| ------------------------ | -------------------------------------------------------------------------------- |
| **`xargs`** | No safe generic “spawn any argv” from **`/bin`** in this runtime; use the shell. |
| **`getconf`** | No **`sysconf`** path. |
| **`chown`**, **`chgrp`** | Ownership changes not modeled for multi-user Hyperdrive. |
| **`mkfifo`** | No FIFO VFS. |
All other commands from **`build.mjs`** not listed here follow the summaries in [Chapter 6](06-kernel-and-binaries.md) or their **`src/*.js`** files.
**Exports for tests / tools:** **`splitTokensBySemicolon`**, **`splitTokensByAndOr`** (same module as **`tokenize`**).
---
## 6. `sed` implementation
+1 -1
View File
@@ -26,7 +26,7 @@ This project is **experimental research software**: a distributed **system image
| [06 — Kernel and binaries](06-kernel-and-binaries.md) | `/boot/init.js`, coreutils catalog |
| [07 — Operations and development](07-operations-and-development.md) | Env vars, npm scripts, CI, Pear, troubleshooting |
| [08 — Git on Bare OS](08-git-on-bare-os.md) | isomorphic-git, VFS fs adapter, HTTP modes |
| [09 — POSIX utilities, shell, VFS](09-posix-utilities-shell-and-vfs.md) | XCU-style `/bin`, `sed`/`awk`, builtins, `mkdir`, stubs, divergence from Issue 7 |
| [09 — POSIX utilities, shell, VFS](09-posix-utilities-shell-and-vfs.md) | XCU-style `/bin`, `sed`/`awk`, shell **`;`/`&&`/`||`**, `getconf`/`xargs` subsets, stubs, divergence from Issue 7 |
| [10 — Manual pages and online help](10-manpages-and-online-help.md) | `man(1)`, `/share/man/man.json`, schema, build, relationship to `help` |
**Companion — developer guide** (how to write `run(ctx, argv)` / `start(ctx)`, extend `/bin`, testing): [developer-guide/README.md](../developer-guide/README.md).