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:
co-authored by
Claude Opus 5
parent
fd962f0084
commit
06af7e7fbb
@@ -227,6 +227,28 @@ python3 -c "open('twoblocks.txt','w').write('the second disk, at length. ' * 20)
|
||||
"$ROOT/Programs/CosmOS/Apps/Copy.asm" -o "$WORK/Copy.sbx" >/dev/null
|
||||
"$TOOL" put "$DISKS/cosmos.img" "$WORK/Copy.sbx" /Apps/Copy.sbx >/dev/null
|
||||
"$TOOL" put "$DISKS/cosmos.img" "$WORK/Say.sbx" /Apps/Say.sbx >/dev/null
|
||||
# A SCRIPT in the system's place, which is the one thing on this disk that is fetched from
|
||||
# drive 0 a block at a time WHILE it runs. Its own name carries the drive in front of it,
|
||||
# and resolving a name like that moves the machine to that drive - so a script started from
|
||||
# another disk would run its lines on this one unless something puts the drive back between
|
||||
# every block. All it does is say where it thinks it is, twice, with a move in between.
|
||||
python3 -c "
|
||||
# LONGER THAN A BLOCK on purpose, twice over. A script that fits in one block is read
|
||||
# entirely while it is being opened, and the opening is not the hard part - the refills are,
|
||||
# because they happen after the drive has been given back to whoever typed the name.
|
||||
#
|
||||
# And it moves itself between the two refills, which is the second half of the same rule: a
|
||||
# script that goes to another disk has to stay there, so a refill puts back the drive the
|
||||
# script left the machine on and not the one it was opened from.
|
||||
def pad(so_far):
|
||||
out = ''
|
||||
while so_far + len(out) < 300:
|
||||
out += '; pad\\n'
|
||||
return out
|
||||
one = '#!\\necho the script is running\\ndrive\\n'
|
||||
two = 'drive 0\\n'
|
||||
open('where.sh', 'w').write(one + pad(len(one)) + two + pad(len(two)) + 'drive\\n')"
|
||||
"$TOOL" put "$DISKS/cosmos.img" where.sh /Apps/where.sh >/dev/null
|
||||
|
||||
# ---- Scripts, including the ones that are meant to go wrong ----
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user