diff options
| author | salmonik <salmonik@tuta.io> | 2026-08-01 13:51:28 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-08-01 13:51:28 +0200 |
| commit | 7d8c0ab9e1279e1aeb48ad6968533b4b07efad95 (patch) | |
| tree | 7d2cfd93ef7d35368280f5a412e63f292916d874 /CONTEXT.md | |
| parent | shell: keyword redirection + post-filter flags (ADR 0002) (diff) | |
| download | rs-dos-7d8c0ab9e1279e1aeb48ad6968533b4b07efad95.tar.gz rs-dos-7d8c0ab9e1279e1aeb48ad6968533b4b07efad95.zip | |
shell: cat <path> TIL <marker> sugar + precise ordering errors
- `cat/hexdump <path> TIL <marker>` is now sugar for `USE <path> TIL
<marker>`: the paths are the input source, truncated at the first
marker line across the combined stream. Path args + USE stays a
syntax error (two input sources), now with a message that says so.
- The parser's `trailing` flag conflated filters with the output
keyword, so `cat f TO out TIL m` blamed the filters. USE/TIL now
distinguish "before the filters" from "before the output keyword",
and filters after the output keyword (`TO out -h 2`) are now
rejected instead of silently accepted.
- cat_file_until/hexdump_file_until return a tri-state (Done/Marker/
Aborted) so multi-path TIL truncation stops at the first marker.
Verified in QEMU (10 checks): truncation, combined-stream marker,
filters after the sugar, heredoc round trip, all four ordering-error
messages, USE-with-paths ambiguity, fsck clean.
Diffstat (limited to 'CONTEXT.md')
| -rw-r--r-- | CONTEXT.md | 41 |
1 files changed, 35 insertions, 6 deletions
| @@ -375,6 +375,12 @@ Resolved this session: | |||
| 375 | All other commands reject input keywords with a syntax error — a | 375 | All other commands reject input keywords with a syntax error — a |
| 376 | command declares whether it takes input. `USE`/`TIL` are general | 376 | command declares whether it takes input. `USE`/`TIL` are general |
| 377 | building blocks; more consumers will come later. | 377 | building blocks; more consumers will come later. |
| 378 | - **`cat <path> TIL <marker>` is sugar for `cat USE <path> TIL | ||
| 379 | <marker>`** (refined this session): the paths are the input source, | ||
| 380 | truncated at the first marker line across the combined stream — | ||
| 381 | `cat a b TIL m` reads `a` then `b` and stops at the first `m` line. | ||
| 382 | The single-source reading is unambiguous, so path args + `TIL` is | ||
| 383 | valid; path args + `USE` stays a syntax error (two input sources). | ||
| 378 | - **Keywords: uppercase-only, aliases valid.** `WRITE`==`WRITING`, | 384 | - **Keywords: uppercase-only, aliases valid.** `WRITE`==`WRITING`, |
| 379 | `TIL`==`UNTIL`, `USE`==`USING`; lowercase forms are ordinary text, so | 385 | `TIL`==`UNTIL`, `USE`==`USING`; lowercase forms are ordinary text, so |
| 380 | `echo use the force` can never redirect. Keywords are reserved | 386 | `echo use the force` can never redirect. Keywords are reserved |
| @@ -404,8 +410,9 @@ Assumed edge semantics (flag if wrong): | |||
| 404 | is silent, as `echo >` behaved before. | 410 | is silent, as `echo >` behaved before. |
| 405 | - `-p` pauses terminal output only; with a file sink it is a no-op. | 411 | - `-p` pauses terminal output only; with a file sink it is a no-op. |
| 406 | - `-h N` / `-t N` require N ≥ 1; otherwise syntax error. | 412 | - `-h N` / `-t N` require N ≥ 1; otherwise syntax error. |
| 407 | - `cat p USE s` (path args *and* an input keyword) is a syntax error — | 413 | - `cat p USE s` (path args *and* an explicit source keyword) is a |
| 408 | the input source is ambiguous. `cat USE s` and path-less `cat TIL m` | 414 | syntax error — the input source is ambiguous. `cat USE s`, path-less |
| 415 | `cat TIL m`, and `cat <path> TIL m` (sugar for `USE <path> TIL m`) | ||
| 409 | are the valid input forms. | 416 | are the valid input forms. |
| 410 | - ADR 0002 (`docs/adr/0002-keyword-redirection-and-post-filters.md`) | 417 | - ADR 0002 (`docs/adr/0002-keyword-redirection-and-post-filters.md`) |
| 411 | captures the keyword-redirection + post-filter decision; the ADR is | 418 | captures the keyword-redirection + post-filter decision; the ADR is |
| @@ -455,10 +462,16 @@ Everything above is now implemented in `shell/src/lib.rs`: | |||
| 455 | truncates and writes from offset 0, `TO` appends at current size. | 462 | truncates and writes from offset 0, `TO` appends at current size. |
| 456 | Diagnostics (errors, usage) always go to the terminal, never into | 463 | Diagnostics (errors, usage) always go to the terminal, never into |
| 457 | the pipeline or a file. | 464 | the pipeline or a file. |
| 458 | - **Input consumers** — `cat`/`hexdump`, path-less only: no keyword = | 465 | - **Input consumers** — `cat`/`hexdump`: no keyword = keyboard until |
| 459 | keyboard until ^D, `USE f` = file, `TIL m` = keyboard heredoc, | 466 | ^D, `USE f` = file, `TIL m` = keyboard heredoc, `USE f TIL m` = |
| 460 | `USE f TIL m` = file truncated at the exact marker line (marker and | 467 | file truncated at the exact marker line (marker and everything |
| 461 | everything after discarded). Other commands reject input keywords. | 468 | after discarded), and `cat <path> TIL m` / `hexdump <path> TIL m` = |
| 469 | the paths as source, truncated at the first marker across the | ||
| 470 | combined stream. Other commands reject input keywords. | ||
| 471 | - **Ordering enforcement** — `USE`/`TIL` must precede the filters and | ||
| 472 | the output keyword; filters must precede the output keyword; | ||
| 473 | distinct messages for each violation ("must come before the | ||
| 474 | filters" / "must come before the output keyword"). | ||
| 462 | - **^D** — EOF everywhere, at the prompt it is a no-op (fresh | 475 | - **^D** — EOF everywhere, at the prompt it is a no-op (fresh |
| 463 | prompt); ^C keeps line-cancel / stream-abort; `poweroff`/`exit` | 476 | prompt); ^C keeps line-cancel / stream-abort; `poweroff`/`exit` |
| 464 | are the only shutdown verbs. | 477 | are the only shutdown verbs. |
| @@ -474,9 +487,25 @@ Bugs found by QEMU verification and fixed: | |||
| 474 | 2. `cat USE f TIL m` leaked everything after the marker — the | 487 | 2. `cat USE f TIL m` leaked everything after the marker — the |
| 475 | final-partial-line emit ran even after the marker break; fixed | 488 | final-partial-line emit ran even after the marker break; fixed |
| 476 | with a `stopped` flag in `cat_file_until`/`hexdump_file_until`. | 489 | with a `stopped` flag in `cat_file_until`/`hexdump_file_until`. |
| 490 | 3. `cat file TO out TIL m` blamed the filters — the `trailing` flag | ||
| 491 | was set by both filters and the output keyword, so the "must come | ||
| 492 | before the filters" error fired for the output keyword too; the | ||
| 493 | parser now distinguishes them (`TO dst TIL m` → "TIL must come | ||
| 494 | before the output keyword"). Also: filters after the output | ||
| 495 | keyword (`TO dst -h 2`) were silently accepted — now a syntax | ||
| 496 | error. | ||
| 497 | 4. `cat file TIL m` was rejected as ambiguous — path args + `TIL` is | ||
| 498 | now sugar for `USE <path> TIL <marker>` (single source, truncated | ||
| 499 | at the marker); path args + `USE` remains a syntax error. | ||
| 477 | 500 | ||
| 478 | Verified: 26 grammar checks pass on a fresh disk *and* on a reused | 501 | Verified: 26 grammar checks pass on a fresh disk *and* on a reused |
| 479 | one (rewriting existing files), `make test-disk` round trip is | 502 | one (rewriting existing files), `make test-disk` round trip is |
| 480 | fsck-clean, the `-p` pager pauses at screenfuls and resumes on | 503 | fsck-clean, the `-p` pager pauses at screenfuls and resumes on |
| 481 | keypress, `-h` stops `/dev/mem` at exactly N lines, and ^C flushes a | 504 | keypress, `-h` stops `/dev/mem` at exactly N lines, and ^C flushes a |
| 482 | `-t` window on an infinite stream. | 505 | `-t` window on an infinite stream. |
| 506 | |||
| 507 | Follow-up verification (this session): 10 checks pass in QEMU for the | ||
| 508 | `cat <path> TIL <marker>` sugar — truncation at the marker, combined | ||
| 509 | multi-path stream truncated at the first marker, filters after the | ||
| 510 | sugar (`-h 1`), the heredoc round trip, all four ordering-error | ||
| 511 | messages, and the `USE`-with-paths ambiguity message; fsck clean. | ||
