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
+16
-3
@@ -487,8 +487,8 @@ printf 'and these are the very different notes in B\n' > notesB.txt
|
||||
"$ROOT/Programs/CosmOS/Apps/Wander.asm" -o "$WORK/Wander.sbx" >/dev/null
|
||||
"$TOOL" put "$DISKS/cwd.img" "$WORK/Wander.sbx" /Apps/Wander.sbx >/dev/null
|
||||
|
||||
# A disk for invoking a program by typing its name. Four files, each there to say one
|
||||
# thing about how a typed word turns into a file name.
|
||||
# A disk for invoking a program by typing its name. Every file on it is there to say one
|
||||
# thing about how a typed word turns into a file that runs.
|
||||
#
|
||||
# dir.sbx is a working program under the name of a built-in command, which is the only way
|
||||
# to check that the built-ins really are tried first. If the search ever moved ahead of the
|
||||
@@ -496,15 +496,28 @@ printf 'and these are the very different notes in B\n' > notesB.txt
|
||||
#
|
||||
# notes.sbx is text under a program's name, so that a file that IS found and IS NOT a
|
||||
# program can be told apart from a word that names nothing. notes.txt is the same text
|
||||
# under its own name, which no typed word can reach: "notes.txt" looks for notes.txt.sbx.
|
||||
# under its own name - which the shell could not reach at all until it began trying the
|
||||
# word as typed, because "notes.txt" only ever looked for notes.txt.sbx.
|
||||
#
|
||||
# Greet is a program with NO extension, and hello.sh is a script. Neither could be started
|
||||
# by typing its name before the shell decided what to run by reading it, and between them
|
||||
# they are the whole of that claim: SBEX loads, #! is read as lines, and the name says
|
||||
# nothing about which happened. /Apps/away.sh is the same for a script found somewhere
|
||||
# other than where you are standing.
|
||||
"$TOOL" format "$DISKS/invoke.img" 64 2 >/dev/null
|
||||
"$ROOT/Assembler" -I "$ROOT/Programs/CosmOS/Source" \
|
||||
"$ROOT/Programs/CosmOS/Apps/Say.asm" -o "$WORK/Say.sbx" >/dev/null
|
||||
"$TOOL" put "$DISKS/invoke.img" "$WORK/Say.sbx" >/dev/null
|
||||
"$TOOL" put "$DISKS/invoke.img" "$WORK/Say.sbx" dir.sbx >/dev/null
|
||||
"$TOOL" put "$DISKS/invoke.img" "$WORK/Say.sbx" Greet >/dev/null
|
||||
printf 'this is not a program' > notes.txt
|
||||
"$TOOL" put "$DISKS/invoke.img" notes.txt >/dev/null
|
||||
"$TOOL" put "$DISKS/invoke.img" notes.txt notes.sbx >/dev/null
|
||||
printf '#!\necho a script, started by its name\n' > "$WORK/hello.sh"
|
||||
"$TOOL" put "$DISKS/invoke.img" "$WORK/hello.sh" hello.sh >/dev/null
|
||||
"$TOOL" mkdir "$DISKS/invoke.img" /Apps >/dev/null
|
||||
printf '#!\necho a script from the system place\n' > "$WORK/away.sh"
|
||||
"$TOOL" put "$DISKS/invoke.img" "$WORK/away.sh" /Apps/away.sh >/dev/null
|
||||
|
||||
# A disk for the assembler that runs on the machine. It holds a source file and the two
|
||||
# programs that check the front end - the reader on its own and the tokenizer on its own -
|
||||
|
||||
Reference in New Issue
Block a user