Phase 3: $(...), aliases, a start-up file, PROMPT, Done lines, >&2
- $(...) runs in a subshell. A word that is only an unquoted $(...) is one word per line. X=$(cmd) sets $? to its status. - alias, unalias, and command NAME. An alias is one pipe. - ~/.config/bjosh/rc runs before the first prompt. - PROMPT, expanded as in double quotes, with \w \W \u \h \$ \e \n. - "Done" lines are written above the input while the prompt waits. - >&2, for programs and value commands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f54ceb35af
commit
f8c4ad64bc
13 changed files with 680 additions and 128 deletions
59
plan.org
59
plan.org
|
|
@ -305,6 +305,65 @@ the text above:*
|
|||
once.
|
||||
- A prompt that the user sets.
|
||||
|
||||
*The design of phase 3 (2026-12-01), implemented the same day:*
|
||||
- ~$(...)~:
|
||||
- The parser reads the lines inside, up to the ~)~ that closes it, in
|
||||
words and in double quotes. ~`...`~ stays an error.
|
||||
- It runs in the shell, as a subshell: a copy of the variables, no job
|
||||
control, and ~exit~ ends only it. Its output is what it writes:
|
||||
programs (through a filter at the end of the form), shell commands,
|
||||
and value commands, which write lines, not a table. Its stdin is the
|
||||
shell's.
|
||||
- The text loses its last line breaks. A word that is only an unquoted
|
||||
~$(...)~ is one word per line, with empty lines left out, so
|
||||
~kill $(pgrep x)~ works and a file name with spaces stays one word.
|
||||
Elsewhere, and in double quotes, it is text in the word.
|
||||
- ~$?~ after a line is the status of the line, not of the ~$(...)~.
|
||||
- Aliases:
|
||||
- ~alias NAME=TEXT~ sets one, ~alias~ lists them, ~alias NAME~ shows one,
|
||||
~unalias NAME~ removes one.
|
||||
- TEXT must be one pipe: no ~;~, ~&&~, ~||~ or ~&~. It is checked when
|
||||
the alias is set.
|
||||
- The first word of a command is an alias when it is plain text, not
|
||||
quoted. The pipe of the alias takes the place of the command: the
|
||||
words and redirections after the name go to its last command, the
|
||||
assignments to its first. An alias in the alias is expanded too, but
|
||||
not the same name again.
|
||||
- ~command NAME ARGS~ runs the program NAME: no alias, no value command.
|
||||
~type~ shows aliases.
|
||||
- The start-up file: ~$XDG_CONFIG_HOME/bjosh/rc~, or ~~/.config/bjosh/rc~.
|
||||
Its lines run before the first prompt of an interactive shell, not for
|
||||
~-c~ or a file.
|
||||
- The prompt: the variable ~PROMPT~, when it is set. It is expanded as text
|
||||
in double quotes (~$NAME~, ~$(...)~, ~$?~), with these escapes:
|
||||
~\w~ (the directory, with ~~~), ~\W~ (its last name), ~\u~ (the user),
|
||||
~\h~ (the host), ~\$~ (~#~ for root, else ~$~), ~\e~ (ESC, for
|
||||
colors), ~\n~, ~\\~. Without ~PROMPT~ the prompt is as before.
|
||||
- "Done" lines at once: bjoterm's ~line-read~ gets ~#:notices~, a function
|
||||
it calls every 200 ms while it waits for a key. The lines it returns are
|
||||
written above the input, which is drawn again below them. The shell
|
||||
gives it the lines of the jobs that changed.
|
||||
- ~>&2~: ~(std run)~ gets ~output-to-errors~. The command's stdout is a
|
||||
pipe that the shell copies to stderr (or to the file of an
|
||||
~errors-into-file~ around it). Value commands take ~>&2~ too.
|
||||
|
||||
*Where the code differs from the design, and what is left:*
|
||||
- ~NAME=value command~ was done in phase 1.
|
||||
- ~X=$(cmd)~ alone sets ~$?~ to the status of the ~$(...)~, as in POSIX,
|
||||
so ~X=$(cmd) || ...~ works. Otherwise ~$?~ is the status of the line.
|
||||
- In ~$(...)~, ~cd~ is undone after it, with ~PWD~ and ~OLDPWD~. A
|
||||
variable that it exports stays in the environment.
|
||||
- ~>&2~ cannot be combined with ~>~, ~>>~, ~2>~, ~2>>~ or ~2>&1~ on the
|
||||
same command: the order of the two would matter. A stage with ~>&2~
|
||||
before another one in a pipe is an error, as one with ~>~ is.
|
||||
- An alias of its own name (~alias ls='ls -d'~) runs the program.
|
||||
- The completer does not complete aliases yet.
|
||||
- Tests: ~tests/syntax.bjo~ (72), ~tests/expand.bjo~ (26),
|
||||
~tests/editor.bjo~ (24), ~tests/run.bjo~ (60), ~tests/values.bjo~
|
||||
(59), ~tests/interactive.bjo~ (16). bjoterm's
|
||||
~tests/line-terminal.bjo~ tests ~#:notices~; Bjolang's test 622 tests
|
||||
~output-to-errors~.
|
||||
|
||||
** Phase 4: later
|
||||
|
||||
- Commands that users write in Bjolang, compiled, and loaded at start-up
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue