ls, a listing laid out to be read
> ls Copy.sbx Say.sbx Where.sbx Walk.sbx ls.sbx Lander where.sh dir says what is there one line each, with sizes and a tally of the disk. This says the names in columns and nothing else, which is what you want ninety times in a hundred. Two programs rather than one with a switch, because they answer different questions and neither answer is a worse version of the other. AND THIS IS A PROGRAM WHERE DIR IS BUILT IN, which is the difference that matters when the disk is what you are doubting: dir is already in memory and this has to be loaded off the disk it is about to list. The daily driver and the diagnostic. Two passes over the directory and no buffer at all. Columns need the longest name before the first line can be printed, which usually means holding every name - twenty four bytes each against a format that allows 1,024 entries. Walking twice costs a read of each directory block, into a buffer that is already there. Across and not down. Real listings go down the columns so that names next to each other alphabetically are next to each other on the screen, and that reason depends on sorting - which nothing here does. With the order arbitrary, down-and-across buys nothing and costs a division. Directories in blue and wearing a separator, unfinished saves in red, everything else plain: whether a file is runnable cannot be known without opening it, and opening every file in a directory to colour a listing is a price nobody agreed to pay. The colour reaches a terminal as well as the screen, so it is one mechanism and not two. ---- Three bugs, and one of them is this machine's oldest trap ---- nameLength answered in A, and a RET puts A back the way the caller had it. So it answered with nothing, and every gap between the columns came out the same width because the padding was subtracting whatever A happened to hold. Q is the ALU's output and nothing puts it back, which is why every answer here comes home in it. The padding subtracted the other way round - the name from the cell - which borrowed on every name that was not the longest, so all of them took the "wider than its cell" path and the listing came out separated by one space. And padding after a name left trailing spaces on every line that did not fill its last column. It goes before the next name now, so spaces only ever fall between two things and a line ends on a name. 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
323d7a0330
commit
a13bbeb4db
@@ -1051,6 +1051,23 @@ cosmosWalk | CosmOS/Source/cosmos.asm | run | cosmosWal
|
||||
# when it differs from the free total, so the first listing is silent about it and the second
|
||||
# is not - a line that appears only when something is wrong is a line somebody reads.
|
||||
cosmosSpace | CosmOS/Source/cosmos.asm | run | cosmosSpace.in | 200000000 | disks/cosmos.img+disks/holes.img
|
||||
# ---- A listing laid out to be read ----
|
||||
#
|
||||
# dir says what is there one line each with sizes and a tally; ls says the names in columns.
|
||||
# Two programs rather than one with a switch, because they answer different questions - and ls
|
||||
# is a PROGRAM where dir is built in, which is the difference that matters when the disk is
|
||||
# what you are doubting.
|
||||
#
|
||||
# TWO PASSES AND NO BUFFER. Columns need the longest name before the first line can be
|
||||
# printed, which usually means holding every name in memory - twenty four bytes each against a
|
||||
# format that allows 1,024 entries. So the directory is walked twice instead, which is the
|
||||
# first thing osDirFirst made possible that dir could not already do.
|
||||
#
|
||||
# Five things in one session: the root, where the directories are coloured and wear a
|
||||
# separator; a subdirectory; a directory named as an argument, which changes there and lets
|
||||
# the shell put it back; an EMPTY one, which says nothing at all rather than saying so; and a
|
||||
# name that is not a directory, which says so and fails.
|
||||
cosmosLs | CosmOS/Source/cosmos.asm | run | cosmosLs.in | 200000000 | disks/cosmos.img
|
||||
# ---- Starting itself ----
|
||||
#
|
||||
# /System/Boot/startup.sh runs before anybody can type. This one is also the check on #quiet
|
||||
|
||||
Reference in New Issue
Block a user