Phase 1: POSIX command lines, job control and the prompt

- (bjosh syntax): a part of POSIX sh, parsed with (text
  parser-combinators). Syntax that is not supported raises an error that
  names it.
- (bjosh expand): variables, ~ and globs. Values are not split.
- (bjosh exec): pipes as (std run) jobs, && || ; &, redirections, and
  NAME=value through env.
- (bjosh shell) and (bjosh builtins): the job table and cd, pwd, exit,
  export, unset, jobs, fg, bg, kill, type, help, history.
- (bjosh editor): Enter waits for open quotes and trailing operators;
  completion of commands and files.
- -c LINE, FILE, and stdin. A Native AOT build too.
- Tests: the parser, expansion, the editor, lines through -c, and job
  control under script.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Linus Björnstam 2026-12-01 06:19:45 +01:00
parent 7f585bd0b2
commit 3518b7711d
16 changed files with 1964 additions and 3 deletions

View file

@ -202,6 +202,33 @@ JSON is the format at the edge, not between built-ins.
or ~vim~ stopped and brought back; Ctrl-C of a job.
- Try a Native AOT build (~(aot #t)~), for start-up time.
*Implemented (2026-11-30). Where the code differs from the text above:*
- Modules: ~syntax~, ~expand~, ~shell~ (the state, variables and the job
table), ~builtins~, ~exec~ (lines to forms), ~editor~ (~input-done?~ and
the completer), ~main~.
- ~NAME=value command~ is done, not phase 3: the program runs through
~env NAME=value~.
- Shell commands cannot have assignments or redirections yet, and cannot
be in a pipe or run with ~&~. Phase 2 makes them value commands.
- ~&~ runs one pipe, not a list with ~&&~ or ~||~, and needs job control.
- Without job control (~-c~, a file, stdin), ~run/interactive~ runs the
forms, so the status of a pipe is that of its last command. With job
control it is ~job-result~'s rule (decision 7).
- Job changes are found by ~job-state~ before each prompt, not by
~job-next-change~. That needs no fiber.
- ~export X=~ removes ~X~: ~set-environment-variable!~ removes a variable
for the empty string.
- Ctrl-Z at the prompt rings the bell: bjoterm's ~make-line-editor~ got
~#:suspend?~ for it. Without it, the shell stopped itself.
- Native AOT works: ~src/main~ starts in under 10 ms, against 110 ms with
~dotnet~.
- Tests: ~tests/syntax.bjo~ (56), ~tests/expand.bjo~ (20),
~tests/editor.bjo~ (24), ~tests/run.bjo~ (31, with ~-c~), and
~tests/interactive.bjo~ (8, under ~script~). ~less~ stopped with Ctrl-Z
and brought back with ~fg~ works; it is not in the tests.
- Not done: the test of decision 4 (short names against ~PATH~). There
are no value commands yet.
** Phase 2: values
- First: the ~(std run)~ change of decision 10, in the Bjolang repo.