The shell edits the line it is given

Three different things used to do this job, and which one you got depended on
where the machine was running. On a terminal the host held the line and did the
echoing and the backspacing; behind a window the console's own gatherer did it;
from a file nothing did it at all. One job, three implementations, none of them
in the system - which is why there was no way to move about in a line and
nowhere for a history to live.

So editLine does it. Key mode while a line is being read and line mode straight
after, so nothing else in the system and no program calling osReadLine notices
anything changed. Left and Right, Home and End, Backspace for the character
before the cursor and Delete for the one under it, and anything typed goes in
where the cursor is with the rest of the line moving along.

Ctrl-D means the end of input again, on an empty line, because that was a thing
the terminal did while it was holding the line and it is not holding it now.
Same trade as the echoing.

MOST KEYSTROKES DRAW NOTHING BUT THEMSELVES. A character typed at the end of a
line needs no cursor moved: printing it is the whole change, and a backspace
there is three ordinary bytes. That matters beyond speed - moving the cursor by
hand is what a terminal is TOLD about, in an escape sequence, so redrawing on
every keypress would fill every recorded transcript in this suite with them.
The line is only reprinted when something happened in the middle of it.

Where the line STARTS is worked out backwards from where printing ended, rather
than trusted from what was remembered. That is what makes it survive the screen
scrolling: a line printed on the bottom row moves everything up by one, and a
remembered row would be one too low from then on.

The command line holds 127 characters, up from 63. The limit started to be felt
the moment a line could be moved about in.

58 recordings changed, and every one of them by the echo. THE PROOF IS NOT A
HEURISTIC: a CosmOS built with the echo silenced reproduces 187 of the 188
recordings byte for byte. The one exception is cosmosTyped, the backspace test,
where the rub-out marks now come from the shell instead of from the console's
gatherer - same marks, different author.

cosmosEditKeys is the new test, and every line in it is typed wrong and then
corrected with a different key. Its last line is eighty six characters at a
prompt in column two on an eighty column screen, so the line runs onto the row
below and the shell has to find the start of something it can no longer see;
breaking either half of that arithmetic fails it.

Also: agree.sh looked for "> the same", anchored to a prompt that no longer
precedes what a command prints.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-08-31 23:01:55 -04:00
co-authored by Claude Opus 5
parent b3726c950a
commit 736037462e
62 changed files with 1220 additions and 291 deletions
+42 -22
View File
@@ -1,36 +1,56 @@
CosmOS
> Apps <dir>
> dir
Apps <dir>
A <dir>
B <dir>
0 files, 3 directories
> /A> Say.sbx 53
> cd /A
/A> dir
Say.sbx 53
notes.txt 25
2 files
/A> these are the notes in A
finished
/A> /B> and these are the very different notes in B
finished
/B> it says: reached the one in Apps
finished
/B> /A> Hello, World!
finished
/A> > Apps <dir>
A <dir>
B <dir>
0 files, 3 directories
> /B> these are the notes in A
finished
/B> moved, and reading a bare name from there:
/A> Type notes.txt
these are the notes in A
finished
/B> and these are the very different notes in B
/A> cd /B
/B> Type notes.txt
and these are the very different notes in B
finished
/B> no such file
/B> that is not a directory
/B> > Apps <dir>
/B> Say reached the one in Apps
it says: reached the one in Apps
finished
/B> cd /A
/A> Say reached the one in A
Hello, World!
finished
/A> cd ..
> dir
Apps <dir>
A <dir>
B <dir>
0 files, 3 directories
> halted
> cd /B
/B> Type ../A/notes.txt
these are the notes in A
finished
/B> Wander /A
moved, and reading a bare name from there:
these are the notes in A
finished
/B> Type notes.txt
and these are the very different notes in B
finished
/B> cd nosuchplace
no such file
/B> cd notes.txt
that is not a directory
/B> cd /
> dir
Apps <dir>
A <dir>
B <dir>
0 files, 3 directories
> exit
halted
Execution halted.
[exit 0]