Phase 2: jobs and history as values, redirections of value commands

- jobs and history are value sources in a pipe; alone they write text.
- < on the first value command of a group, > and >> on the last,
  which then writes lines. A value command after > is an error.
- File errors use fs-error-message, without a stack trace.
- plan.org: Ctrl-C does not cancel a blocking read of a terminal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Linus Björnstam 2026-12-01 07:21:04 +01:00
parent 027acc84e6
commit acd84a2a4c
8 changed files with 252 additions and 71 deletions

View file

@ -96,8 +96,26 @@
"err: bjosh: first: not a count: x\ncode: 1")
(expect "a bad regular expression" (c "l | wh name =~ '('")
"err: bjosh: where: not a regular expression: (\ncode: 1")
(expect "a redirection of a value command" (c "l > f")
"err: bjosh: l: assignments and redirections of value commands are not supported yet\ncode: 2")
;; Redirections.
(expect "> writes lines" (c "l > out.txt; wc -l < out.txt") "5")
(expect ">> appends" (c "l | g name > out.txt; l | g name >> out.txt; wc -l < out.txt") "10")
(expect "< reads a file" (c "o a.txt | rv > r.txt; so < r.txt") "one\ntwo")
(expect "< into a pipe with a program" (c "so < a.txt | tr a-z A-Z") "ONE\nTWO")
(expect "> after a program" (c "cat a.txt | rv > r.txt; cat r.txt") "two\none")
(expect "< on a file that is not there" (string-starts-with? (c "so < nosuch") "err: bjosh: not found: nosuch: ") #t)
(expect "< after another value command" (c "n | so < a.txt")
"err: bjosh: so: < on a value command after another one\ncode: 2")
(expect "a value command after >" (c "l > f | n")
"err: bjosh: n: the value command before it writes to a file, so nothing can be piped into it\ncode: 2")
(expect "2> of a value command" (c "l 2> e")
"err: bjosh: l: 2>, 2>&1 and >&2 of value commands are not supported yet\ncode: 2")
(expect "an assignment of a value command" (c "X=1 l")
"err: bjosh: l: assignments of value commands are not supported\ncode: 2")
;; Shell commands as values, in a pipe.
(expect "jobs in a pipe, without jobs" (c "jobs | n") "0")
(expect "history in a pipe, without an editor" (c "history | n") "0")
;; Names (decision 4).
(expect "a long name that is a program runs the program" (c "printf 'a\\na\\n' | uniq -c") " 2 a")