From 6eb14b64209b9d24554c587f610d7e300ef809ea Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 1 Aug 2026 13:14:07 +0200 Subject: shell: keyword redirection + post-filter flags (ADR 0002) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement the shell experience redesign: one canonical grammar for every command — 'cmd args [USE src] [TIL marker] [filters...] [output kw dst]'. - Keyword redirection (uppercase-only, aliases valid, fully reserved): WRITING/WRITE overwrite, TO append, USE/USING input source, TIL/UNTIL heredoc/terminator (exact full-line marker). > >> < << are removed; '>' is plain text. - Post-filter stages applied left to right over a line stream, each repeatable: -h N (head kills the upstream), -t N (tail holds a rolling window, flushes at EOF/^C), -g PAT (smart-case literal substring), -p (screenful pager, terminal only). A file sink replaces the screen; -p is a no-op with one. - C-style quoting: "..." groups and literalizes, \x escapes one char; quoted/escaped text is never an operator, never split. - Input consumers: cat/hexdump, path-less only (stdin until ^D, USE f, TIL m heredoc, USE f TIL m truncation). Other commands reject input keywords; paths + input keyword is a syntax error. - ^D is EOF everywhere and never powers off; poweroff/exit are the only shutdown verbs. - help rewritten; test-disk.sh and sendkeys.py use the keyword syntax. Verified in QEMU: 26 grammar checks on fresh and reused disks, disk round trip, pager pacing, -h stopping /dev/mem at N lines, ^C flushing a -t window. Two bugs found during verification and fixed: 1. WRITING over an existing file wrote after stale NUL padding — fs::size() is stale after set_len(0); the sink writes at offset 0 after truncation. 2. USE f TIL m leaked the post-marker remainder — the final partial-line emit ran after the marker break; guarded with a stopped flag. --- scripts/test-disk.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/test-disk.sh') diff --git a/scripts/test-disk.sh b/scripts/test-disk.sh index f7337ef..11a9b05 100755 --- a/scripts/test-disk.sh +++ b/scripts/test-disk.sh @@ -99,14 +99,14 @@ VOL_UID="$(grep -a 'fat: mounted' "$LOG" | sed -n 's/.*at \/disk\/\([^ )]*\).*/\ [ -n "$VOL_UID" ] || fail "no FAT32 volume was mounted (look for 'fat: mounted' in the log)" echo " mounted volume UID: $VOL_UID" -echo "==> 4/6 drive the shell (ls / mkdir / echo > / cat / poweroff)" +echo "==> 4/6 drive the shell (ls / mkdir / echo WRITING / cat / poweroff)" # The filename is deliberately >13 chars so the FAT LFN path gets # multi-entry entries (they're stored last-first on disk). TESTFILE="disk-test-$STAMP.txt" python3 "$SCRIPT_DIR/sendkeys.py" --sock "$SOCK" \ "ls /disk" \ "mkdir /disk/$VOL_UID/sub" \ - "echo disk-test-$STAMP > /disk/$VOL_UID/sub/$TESTFILE" \ + "echo disk-test-$STAMP WRITING /disk/$VOL_UID/sub/$TESTFILE" \ "cat /disk/$VOL_UID/sub/$TESTFILE" \ "poweroff" -- cgit v1.2.3