Reading a script must not move the person who started it

A script is fetched a block at a time while its lines run, and its name
is resolved afresh for every block. A name with a drive in front of it
moves the machine to that drive on the way past - sbfsWalk calls sbfsUse
- so a script found in the system's place on drive 0, started by somebody
standing on a disk of their own, ran its lines on the system disk.

Always possible with "do 0:/Apps/setup.sh", and reachable by typing a
name now that the search finds scripts the same three places it finds
programs. The drive is kept across each fetch and put back after it, at
both places a script's name is resolved.

The test has to work for it. A script that fits in one block is read
entirely while it is being opened, and the opening was never the hard
part; and the keep in scriptFill cannot be broken on its own, because
scriptOpen has already written the variable down. So the script on the
disk crosses two block boundaries and moves itself between them: what it
says about where it is standing is 1 before the move and 0 after.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-09-06 13:23:31 -04:00
co-authored by Claude Opus 5
parent fd962f0084
commit 06af7e7fbb
6 changed files with 102 additions and 1 deletions
+13
View File
@@ -1123,6 +1123,19 @@ cosmosDrivePath | CosmOS/Source/cosmos.asm | run | cosmosDri
# place the shell looks. The drive it says afterwards is the check that fetching a program
# did not move the person who ran it.
cosmosCrossDisk | CosmOS/Source/cosmos.asm | run | cosmosCrossDisk.in | 90000000 | disks/cosmos.img+disks/other.img
# ---- And a SCRIPT run from the other disk ----
#
# The same question one step harder. A program is wholly in memory before its first
# instruction runs, so fetching it can move the drive and putting it back afterwards is
# enough. A script is read a block at a time WHILE its lines run, and its name carries the
# drive it lives on - so every refill resolves "0:/Apps/where.sh" and every resolution moves
# the machine to drive 0 unless something puts it back. What the script says about where it
# is standing is the check, and it must say 1.
#
# THEN IT MOVES ITSELF and says so again, across another block boundary. A refill has to put
# back the drive the script left the machine on rather than the one it was opened from, or a
# script that goes to another disk to work is dragged home between two of its own lines.
cosmosScriptDrive | CosmOS/Source/cosmos.asm | run | cosmosScriptDrive.in | 60000000 | disks/cosmos.img+disks/other.img
# ---- A beat a program sets for itself ----
#
# That reading the status is what takes the tick down, and that without the repeat bit it