The shell runs what it reads, not what a name ends in
A typed word had ".sbx" pasted on the end of it before anything went looking, which is why "notes.txt" sent the shell after a notes.txt.sbx that was never going to exist, and why a script could only be started with "do". The extension was what made a file reachable by name. Now the word as typed is asked for first and the word with the extension on it only after that misses. What comes back is dispatched on what is inside it: SBEX loads and starts, "#!" is read as lines. The loader already refuses anything that is not SBEX and the script reader already refuses anything without the shebang, so the two kinds of runnable file turn each other away and neither has to know the other exists. The suffix can only ever be a second guess, so a file that is really there always beats one that would have to be invented and every program already on a disk still starts by the short name people type for it. It costs a second walk of each directory when a word is not found in it. Tab completion offers a file under the name it actually has, and the suffix stripper is gone: a first word can now be any file at all, and offering only the ones ending .sbx would hide the scripts. The video capture windows moved out a hundred thousand cycles, because starting Lander now walks four names where it walked two. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
co-authored by
Claude Opus 5
parent
4e61158b11
commit
fd962f0084
@@ -1744,12 +1744,11 @@ tabIsFirst:
|
||||
; The shell's own commands, only at the front of a line and only when no directory has been
|
||||
; named: nothing with a separator in it was ever going to be "dir".
|
||||
;
|
||||
; And on the disk: programs at the front of a line, since that is all a first word can
|
||||
; usefully be, and anything at all after it.
|
||||
; And on the disk: everything, wherever in the line it is. A first word used to be
|
||||
; narrowed to programs, back when a program was a file ending ".sbx"; now that the shell
|
||||
; runs what it reads, a first word can be any file at all.
|
||||
SETD.1 TabFirst
|
||||
LDA.1
|
||||
SETD.1 TabPrograms
|
||||
STA.1
|
||||
CALL tabRunSources
|
||||
|
||||
SETD.1 TabCount
|
||||
@@ -2261,22 +2260,15 @@ tabEntry:
|
||||
INCD.3
|
||||
RSTA
|
||||
STA.3
|
||||
BRI tabEntryOffer
|
||||
|
||||
tabEntryFile:
|
||||
; A file. When the first word of a line is being finished it can only usefully be a
|
||||
; program, and the name to type for one is the name without its extension - so anything
|
||||
; else is not offered at all rather than offered and useless.
|
||||
SETD.1 TabPrograms
|
||||
LDA.1
|
||||
BRA tabEntryOffer
|
||||
CALL tabStripSbx
|
||||
BNQ tabEntryDone
|
||||
|
||||
tabEntryOffer:
|
||||
; A file, offered under the name it actually has - so nothing happens to it here at all.
|
||||
; A first word used to be offered with ".sbx" taken off, and anything without that ending
|
||||
; not offered, which was right while the extension was what made a file reachable by name.
|
||||
; THE SHELL NOW RUNS WHAT IT READS, so a script and a launcher start by name too, and
|
||||
; hiding them would hide exactly the things a first word is most likely to be.
|
||||
SETD.3 TabCandidate
|
||||
CALL tabOffer
|
||||
tabEntryDone:
|
||||
RET
|
||||
|
||||
; DP0 names a string and DP1 where to put it. Copies up to what a name can be.
|
||||
@@ -2308,62 +2300,6 @@ tabEnd:
|
||||
tabEndDone:
|
||||
RET
|
||||
|
||||
; Takes ".sbx" off the end of TabCandidate. Q is zero if it was there, and one if it was not
|
||||
; - which is how a file that is not a program is passed over.
|
||||
tabStripSbx:
|
||||
; How long the name is, counted rather than measured from a pointer, because what is
|
||||
; wanted next is a NUMBER: four characters back from the end is only a place if there are
|
||||
; four of them to go back over.
|
||||
SETD.0 TabCandidate
|
||||
RSTB
|
||||
tabStripCount:
|
||||
LDA.0
|
||||
BRA tabStripCounted
|
||||
INCD.0
|
||||
INCB
|
||||
BRI tabStripCount
|
||||
tabStripCounted:
|
||||
; The count is in B and wanted in A, and there is no instruction that moves one to the
|
||||
; other: adding it to nothing is how a value crosses from B to A on this machine.
|
||||
RSTA
|
||||
CCF
|
||||
ADD
|
||||
MVQA
|
||||
INIB 0d4
|
||||
CCF
|
||||
SUB
|
||||
BRC tabStripNo ; Shorter than the extension, so it cannot end in it.
|
||||
MVQA
|
||||
SETD.3 TabCandidate
|
||||
DPUA.3 ; Four from the end, which is where the extension would begin.
|
||||
|
||||
SETD.0 SbxText
|
||||
tabStripMatch:
|
||||
LDA.0
|
||||
BRA tabStripYes
|
||||
LDB.3
|
||||
XOR
|
||||
BNQ tabStripNo
|
||||
INCD.0
|
||||
INCD.3
|
||||
BRI tabStripMatch
|
||||
tabStripYes:
|
||||
; It ended in the extension, so the name to type is what comes before it. DP3 was left on
|
||||
; the zero by the comparison, so four back is where the dot was.
|
||||
INIA 0d4
|
||||
DPDA.3
|
||||
RSTA
|
||||
STA.3
|
||||
RSTB
|
||||
CCF
|
||||
ADD ; Q is zero: it is a program.
|
||||
RET
|
||||
tabStripNo:
|
||||
INIA 0x01
|
||||
RSTB
|
||||
CCF
|
||||
ADD ; Q is one: it is not.
|
||||
RET
|
||||
|
||||
; ---- The shell's own words ----
|
||||
;
|
||||
@@ -3501,10 +3437,25 @@ promptUnknown:
|
||||
STA.0
|
||||
|
||||
promptSearch:
|
||||
; ---- The name as typed, and only then the name with ".sbx" on it ----
|
||||
;
|
||||
; The exact word first is what makes a file reachable under the name it actually has: a
|
||||
; script, a launcher, or a program somebody dropped the extension from. The word with the
|
||||
; extension after it is what keeps every program already on a disk startable by the short
|
||||
; name people have always typed for it.
|
||||
;
|
||||
; THE SUFFIX CAN ONLY EVER BE A SECOND GUESS. A file that is really there always wins over
|
||||
; one that would have to be invented, so "notes.txt" stops sending the shell after a
|
||||
; notes.txt.sbx that was never going to exist.
|
||||
RSTA
|
||||
SETD.0 NameSuffix
|
||||
STA.0
|
||||
|
||||
promptSearchName:
|
||||
CALL nameProgram
|
||||
SETD.0 NameOk
|
||||
LDA.0
|
||||
BRA promptElsewhere ; Too long to be a path, so it is not the name of one.
|
||||
BRA promptNextName ; Too long to be a path, so it is not the name of one.
|
||||
|
||||
CALL loadProgram
|
||||
SETD.0 LoadStatus
|
||||
@@ -3526,6 +3477,18 @@ promptNotLoaded:
|
||||
SETD.0 LoadStatus
|
||||
LDA.0
|
||||
|
||||
; ---- Not a program is not the end of it ----
|
||||
;
|
||||
; The file is there and it does not say SBEX. A script says what it is on its own first
|
||||
; line, so the thing to do is read that rather than decide from the name that this could
|
||||
; never have been runnable. THE SHELL RUNS WHAT IT READS, which is the whole point: the
|
||||
; loader turns away anything that is not SBEX and scriptOpen turns away anything without
|
||||
; the shebang, and between them nothing has to know what an extension means.
|
||||
INIB 0d4
|
||||
CCF
|
||||
SUB
|
||||
BRQ promptAsScript
|
||||
|
||||
; No file of that name is not a fault. It is the ordinary case of a word this shell does
|
||||
; not know, and it is the only answer worth looking somewhere else for. Anything else
|
||||
; means a file of that name IS there and something is wrong with it, and answering
|
||||
@@ -3536,6 +3499,52 @@ promptNotLoaded:
|
||||
SUB
|
||||
BNQ loadFailed
|
||||
|
||||
promptNextName:
|
||||
; Nothing of that name in this place. The same place with the extension on, and then the
|
||||
; next place.
|
||||
SETD.0 NameSuffix
|
||||
LDA.0
|
||||
BNA promptElsewhere
|
||||
INCA
|
||||
STA.0
|
||||
BRI promptSearchName
|
||||
|
||||
promptAsScript:
|
||||
; ---- The drive goes back before a script opens ----
|
||||
;
|
||||
; The same handing back that a loaded program gets, and here it has to happen BEFORE the
|
||||
; file is opened rather than after: a program is wholly in memory by then and a script is
|
||||
; read a block at a time as it runs, so the lines in it must run on the disk the person was
|
||||
; standing on. The name itself still says where the script lives, and reading it does not
|
||||
; move anybody - see scriptKeepDrive.
|
||||
SETD.0 SearchDrive
|
||||
LDA.0
|
||||
CALL sbfsUse
|
||||
|
||||
SETD.0 ProgramName
|
||||
CALL scriptOpen
|
||||
BRQ prompt ; It is open, and the next line read will come from it.
|
||||
|
||||
; Which of the two went wrong. There is a file, so "there is no such file" cannot happen.
|
||||
MVQA
|
||||
INIB 0x02
|
||||
CCF
|
||||
SUB
|
||||
BRQ promptNotRunnable
|
||||
SETD.0 ScriptTooDeep
|
||||
BRI fileComplain
|
||||
|
||||
promptNotRunnable:
|
||||
; A file of that name IS there, and it is neither kind of runnable thing. Saying "I do not
|
||||
; know" about it would send somebody looking for a file that is sitting right in front of
|
||||
; them; what is wrong is the file, not the word.
|
||||
SETD.0 NotRunnable
|
||||
CALL printString
|
||||
SETD.0 CommandLine
|
||||
CALL printString
|
||||
CALL newLine
|
||||
BRI commandFailed
|
||||
|
||||
promptElsewhere:
|
||||
; Was that the last place there is?
|
||||
SETD.0 NamePrefix
|
||||
@@ -3814,13 +3823,18 @@ widthDone:
|
||||
|
||||
; ---- Making a file name out of a typed word ----
|
||||
;
|
||||
; Turns what was typed into the name of a file to go and look for. ".sbx" goes on the end
|
||||
; unless it is already there, so that "Snake" and "Snake.sbx" both find the same file.
|
||||
; Turns what was typed into the name of a file to go and look for. Which place to look in is
|
||||
; NamePrefix, and whether to put ".sbx" on the end is NameSuffix - the search calls this once
|
||||
; for each combination and the two answers are two different files to go and ask about.
|
||||
;
|
||||
; THE EXTENSION IS WHAT MAKES A FILE REACHABLE BY NAME. Typing "notes" looks for notes.sbx
|
||||
; and typing "notes.txt" looks for notes.txt.sbx, so a text file cannot be started by
|
||||
; typing what it is called, whatever is inside it. Only load reaches a file by its whole
|
||||
; name, which is why the monitor can still put any file at all in front of itself.
|
||||
; THE EXTENSION USED TO BE WHAT MADE A FILE REACHABLE BY NAME. It went on unconditionally, so
|
||||
; typing "notes" looked for notes.sbx and typing "notes.txt" looked for notes.txt.sbx, and no
|
||||
; text file, script or launcher could be started by typing what it is called. Now the word as
|
||||
; typed is tried first and the extension is only a fallback for the programs that carry one.
|
||||
;
|
||||
; A word that already ends in ".sbx" is refused on the suffix pass rather than named twice:
|
||||
; the exact pass has been there and looked, and asking the disk the same question again is a
|
||||
; walk of a directory for an answer already known.
|
||||
;
|
||||
; NameOk is one if there is a path in ProgramName and zero if the word could not be made
|
||||
; into one. What limits it is the buffer, not the format: each NAME along a path is still
|
||||
@@ -3879,8 +3893,16 @@ nameCopied:
|
||||
SETD.0 NameLeft
|
||||
STB.0
|
||||
|
||||
; The word exactly as typed, which is the first thing asked for and the only thing asked
|
||||
; for when the extension is not wanted.
|
||||
SETD.0 NameSuffix
|
||||
LDA.0
|
||||
BRA nameMade
|
||||
|
||||
; Only a word of four characters or more can already end in ".sbx". Stepping back four to
|
||||
; look at a shorter one would read whatever happens to sit in front of the buffer.
|
||||
SETD.0 NameLeft
|
||||
LDB.0
|
||||
INIA 0d55
|
||||
CCF
|
||||
SUB
|
||||
@@ -3892,7 +3914,7 @@ nameCopied:
|
||||
SETD.0 SbxSuffix
|
||||
nameSuffixSame:
|
||||
LDA.0
|
||||
BRA nameMade ; The suffix ran out with all of it matched.
|
||||
BRA nameDone ; All of it matched, so the exact pass already asked for this.
|
||||
LDB.2
|
||||
CCF
|
||||
SUB
|
||||
@@ -7513,6 +7535,10 @@ ScriptStopped:
|
||||
"stopped: that line did not work"
|
||||
Unknown:
|
||||
"I do not know: "
|
||||
; A file of that name is there and it is neither a program nor a script, which is a different
|
||||
; thing from a word this shell does not know and reads differently to whoever typed it.
|
||||
NotRunnable:
|
||||
"that is not a program or a script: "
|
||||
Farewell:
|
||||
"halted"
|
||||
DirectoryText:
|
||||
@@ -7594,8 +7620,8 @@ DataWord:
|
||||
ExecMagic:
|
||||
"SBEX"
|
||||
|
||||
; What every program on the disk is called, and the four characters that make one
|
||||
; reachable by typing its name.
|
||||
; What every program on the disk is called. It is a convention now rather than a rule: the
|
||||
; shell tries the word as typed first and only puts these four characters on afterwards.
|
||||
SbxSuffix:
|
||||
".sbx"
|
||||
LoadWhat:
|
||||
@@ -7781,8 +7807,6 @@ ForName:
|
||||
ShellNameCount:
|
||||
0d22
|
||||
|
||||
SbxText:
|
||||
".sbx"
|
||||
AppsPath:
|
||||
"/Apps"
|
||||
VarNoSuch:
|
||||
@@ -7864,6 +7888,9 @@ NameOk:
|
||||
0x00
|
||||
NamePrefix:
|
||||
0x00
|
||||
; Nought for the word exactly as typed, one for the word with ".sbx" put on the end.
|
||||
NameSuffix:
|
||||
0x00
|
||||
NameLeft:
|
||||
0x00
|
||||
LoadedEntry:
|
||||
@@ -8206,8 +8233,6 @@ TabCopyAt:
|
||||
0x00
|
||||
TabFirst:
|
||||
0x00
|
||||
TabPrograms:
|
||||
0x00
|
||||
; Whether the walk is looking for the answer or showing what the answers were.
|
||||
TabShowing:
|
||||
0x00
|
||||
|
||||
Reference in New Issue
Block a user