A script is given words, and keeps them
"do build.sh cosmos.asm" looked for a file called "build.sh cosmos.asm", because scriptOpen copied the whole rest of the line into the name. So a script could be told nothing, and a launcher - a script whose entire job is to hand on what it was told - could not exist. Now the name is cut off the front and what follows is kept whole. $1 to $9 are the words of it, walked out on demand, and $args is all of them. Nothing is stored per parameter, so there is no limit on how many a script may be handed and no second number to keep in step. Both ways of starting a script pass them on: "do" and typing the name. A word that was not given is an error that stops the script, like every other name this shell does not know. Expanding it to nothing would let a command run with an argument missing and then report success, which is what stop-on-failure exists to prevent. $args is always set inside a script, empty if it was given nothing, so "if same $args" can be asked. ---- And the count that describes the block was already wrong ---- Found while adding a field to it. The state one script keeps for another is saved by a single copy of a fixed number of bytes, and that number was 71 against a block of 77: six bytes of line position had been added in the middle of it years after the count was written. So the tail of every saved script was never saved, and #quiet in a helper stayed behind in the script that called it - the opposite of what this file's own comment promises and the README documents. The unsaved line position turned out not to matter, because a loop keeps its own copy in the block record. Nothing said so. Three numbers describe this block and all three now say so in a comment, and cosmosScriptNest ends on a helper that goes quiet and a caller that must not stay that way. 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
06af7e7fbb
commit
d9ebc76cf5
@@ -72,7 +72,7 @@ scriptSlotAt:
|
||||
DECA
|
||||
BRA scriptSlotDone
|
||||
scriptSlotStep:
|
||||
DPUP.3 0d71
|
||||
DPUP.3 0d205
|
||||
DECA
|
||||
BNA scriptSlotStep
|
||||
scriptSlotDone:
|
||||
@@ -80,7 +80,7 @@ scriptSlotDone:
|
||||
|
||||
; Seventy bytes, DP0 to DP1.
|
||||
scriptCopyState:
|
||||
INIB 0d71
|
||||
INIB 0d205
|
||||
scriptCopyByte:
|
||||
LDA.0
|
||||
STA.1
|
||||
@@ -154,6 +154,17 @@ scriptOpenFirst:
|
||||
INIB 0d63
|
||||
CALL copyText
|
||||
|
||||
; ---- And what it was given ----
|
||||
;
|
||||
; After the push, so that what the script one level up was given is already somewhere safe.
|
||||
; A script started with nothing gets an EMPTY one rather than none at all, which is what
|
||||
; makes "$args" always mean something inside a script while "$1" can be missing.
|
||||
SETD.1 ScriptArgsFrom
|
||||
LDD.0.1
|
||||
SETD.1 ScriptArgs
|
||||
INIB 0d128
|
||||
CALL copyText
|
||||
|
||||
CALL scriptKeepDrive
|
||||
SETD.0 ScriptName
|
||||
SWI osFileInfo
|
||||
@@ -584,11 +595,30 @@ ScriptDepth:
|
||||
ScriptDrive:
|
||||
0x00
|
||||
|
||||
; ---- Seventy bytes, and they are next to each other on purpose ----
|
||||
; Where the arguments are, for the length of one call to scriptOpen. A pointer rather than the
|
||||
; text, because the text is still sitting in the line that named the script and copying it
|
||||
; twice would buy nothing.
|
||||
ScriptArgsFrom:
|
||||
0x00 0x00
|
||||
|
||||
; ---- Two hundred and five bytes, and they are next to each other on purpose ----
|
||||
;
|
||||
; Name, blocks left, next block, where in the block, and whether it is echoing: the whole of
|
||||
; where a script has got to. Saving it is one copy because of this order, and nothing else
|
||||
; may be put between them.
|
||||
; Name, blocks left, next block, where in the block, what it was given, and whether it is
|
||||
; echoing: the whole of a running script. Saving it is one copy because of this order, and
|
||||
; nothing else may be put between them.
|
||||
;
|
||||
; ---- THREE NUMBERS DESCRIBE THIS BLOCK AND ALL THREE MUST AGREE ----
|
||||
;
|
||||
; scriptCopyState how many bytes one of them is
|
||||
; scriptSlotAt how far apart two saved ones are
|
||||
; ScriptSaved four of them
|
||||
;
|
||||
; They did not agree, and that is what this warning is for. Six bytes of line position were
|
||||
; added in the middle of the block and the count stayed at 71, so the last six bytes of every
|
||||
; saved script were never saved: a nested script's #quiet leaked back out to the script that
|
||||
; called it, which is the opposite of what this file's own comment promises. The line position
|
||||
; that went unsaved with it turned out not to matter - a loop keeps its own copy in the block
|
||||
; record - but nothing said so, and the next field added would have been chosen at random.
|
||||
ScriptName:
|
||||
#Reserve 0d64
|
||||
ScriptBlocks:
|
||||
@@ -617,10 +647,22 @@ ScriptLineBlocks:
|
||||
ScriptQuiet:
|
||||
0x00
|
||||
|
||||
; ---- What the script was given ----
|
||||
;
|
||||
; The rest of the line that started it, kept whole rather than picked apart, because picking
|
||||
; it apart costs a place to put every piece and a limit on how many there may be. "$1" walks
|
||||
; this and copies out the word it wants; "$args" is this.
|
||||
;
|
||||
; A WHOLE LINE OF ROOM, so that nothing a person can type can be cut short. The line is 127
|
||||
; and the script's own name has already come off the front of it, so this can never be filled
|
||||
; - which is worth 128 bytes a level to never have to explain.
|
||||
ScriptArgs:
|
||||
#Reserve 0d128
|
||||
|
||||
; Three would do - a save happens on the second script and not the first - but four costs
|
||||
; seventy bytes and removes an off-by-one from the only place it could hide.
|
||||
; one more and removes an off-by-one from the only place it could hide.
|
||||
ScriptSaved:
|
||||
#Reserve 0d284
|
||||
#Reserve 0d820
|
||||
ScriptInto:
|
||||
0x00 0x00
|
||||
ScriptRoom:
|
||||
|
||||
Reference in New Issue
Block a user