Phase 2, first part: values and value commands
- Values are Json of (text json); a record is JsonFields. - Value commands: files, procs, open, where, select, get, sort-by, first, last, count, reverse, uniq, lines, from-json, to-json, from-csv, to-csv, each with a short name. - Value commands next to each other run as one unit: a (std run) filter in a job, or in the shell when a line has no program. - Records are shown as a table; values go to programs as lines. - A name is a shell command, a short name, a program on PATH, then a long name. - 2>&1, with >FILE 2>&1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3518b7711d
commit
027acc84e6
12 changed files with 1142 additions and 37 deletions
43
plan.org
43
plan.org
|
|
@ -250,11 +250,47 @@ JSON is the format at the edge, not between built-ins.
|
|||
- Tests: each command with ~-c~, and mixed pipes such as
|
||||
~files | where size > 1000 | to-json | jq .name~.
|
||||
|
||||
*Implemented, the first part (2026-12-01). Where the code differs from
|
||||
the text above:*
|
||||
- ~(std run)~ (Bjolang b8c92ff, d808624): a filter can be the first or
|
||||
last stage of a job. The first reads an empty input; the last writes
|
||||
~current-output-port~. ~job-control~ now ignores SIGTTOU, so the
|
||||
write works with ~tostop~ set. ~errors-to-output~ is 2>&1.
|
||||
- ~Value~ is ~Json~ of ~(text json)~, and a record is a ~JsonFields~, which
|
||||
keeps the order of its fields. JSON is read with ~#:objects 'fields~.
|
||||
- Modules: ~values~ (streams, text, tables), ~commands~ (the value
|
||||
commands and their table), ~pipeline~ (value commands next to each
|
||||
other, as one unit).
|
||||
- A stream between value commands is a channel of ~(Option Json)~:
|
||||
~None~ ends it. A unit of value commands runs in one ~with-cancel~
|
||||
scope. A command that raises cancels the others.
|
||||
- Names (decision 4): a shell command, then a short name, then a program
|
||||
on ~PATH~, then a long name. So ~uniq~ and ~last~ are the programs on a
|
||||
machine that has them, and ~u~ and ~tl~ the value commands. The test of
|
||||
decision 4 is in ~tests/values.bjo~.
|
||||
- ~where~ also takes ~eq ne lt le gt ge~: ~<~ and ~>~ are redirections
|
||||
unless quoted. A string that reads as a number is a number against a
|
||||
number.
|
||||
- ~first~ and ~last~ take 10 values unless given a count. ~first~ reads
|
||||
its input to the end after the count, so the stage before it can end.
|
||||
- ~from-json~ reads one document, and gives an array as its values; else
|
||||
one document per line. ~open~ goes by the extension.
|
||||
- Value commands with ~&~, with redirections, or with assignments are an
|
||||
error. A pipe of only value commands runs in the shell, with an empty
|
||||
input; Ctrl-C stops it with status 130.
|
||||
- ~2>&1~ is done (phase 3): ~>FILE 2>&1~ works, ~2>&1 >FILE~ is an error.
|
||||
~>&2~ has no form in ~(std run)~ yet.
|
||||
- Not done: ~jobs~ and ~history~ as values, and ~echo~. A value ~echo~
|
||||
would take the name from ~/bin/echo~, which decision 4 does not allow;
|
||||
to decide.
|
||||
- Tests: ~tests/values.bjo~ (40); ~tests/run.bjo~ (34);
|
||||
~tests/interactive.bjo~ (10).
|
||||
|
||||
** Phase 3: more POSIX, and the rest of the edges
|
||||
|
||||
- ~$(...)~: the output of a line as a word. Its text, with the last line
|
||||
break taken away, as in POSIX.
|
||||
- ~2>&1~ (the ~(std run)~ change of decision 10).
|
||||
- ~2>&1~ (the ~(std run)~ change of decision 10). Done in phase 2.
|
||||
- ~NAME=value command~: the variable for that command only.
|
||||
- Aliases, and a start-up file (~~/.config/bjosh/rc~) of shell lines.
|
||||
- Lines above the input with bjoterm (decision 11), for "Done" lines at
|
||||
|
|
@ -276,9 +312,8 @@ JSON is the format at the edge, not between built-ins.
|
|||
short name. The built-in still wins, and ~command NAME~ runs the
|
||||
program. The test of decision 4 shows a new collision.
|
||||
- *A built-in at the end of a job writes the terminal from the
|
||||
background.* With ~tostop~ set, the shell gets SIGTTOU. ~job-control~
|
||||
catches SIGTTOU (it does not ignore it), so the write could fail or
|
||||
repeat. Find out in the ~(std run)~ change.
|
||||
background.* Solved: ~job-control~ ignores SIGTTOU, so the write goes
|
||||
through with ~tostop~ set. Tested under ~script~.
|
||||
- *Start-up time.* A .NET program starts in about 100 ms. AOT should fix
|
||||
it, if bjoterm's glue and ~(std run)~ work under AOT.
|
||||
- *Ctrl-C during a built-in that blocks.* Cancelling works only at a
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue