This Space for Rent

New Code (reinventing the wheel edition)

I'm not exactly sure how I got the idea into my head, but last weekend I found myself looking at the copy of ls on pell, thinking “there are too many silly options for this program”, looking at the copy of ls on the work machines and thinking, for the approximately 500th time, “the idiot who thought that color-ls was a good idea needs to be hunted down and beaten to death with an accessability handbook”, then looking at the copy of ls on one of the local bsd machines and thinking that that one was too rococo to live with. And soon after I did this I found myself starting to code.

The versions of ls that most Linux boxes are infested with have all the options you can eat, and a usage message that can choke a horse

Usage: o.ls [OPTION]... [PATH]...
-A--almost-alldo not list implied . and ..
-a--alldo not hide entries starting with .
-B--ignore-backupsdo not list implied entries ending with ~
-b--escapeprint octal escapes for nongraphic characters
-Clist entries by columns
-csort by change time; with -l: show ctime
-D--diredgenerate output well suited to Emacs' dired mode
-d--directorylist directory entries instead of contents
-e--full-timelist both date and full time
-F--classifyappend a character for typing each entry
-fdo not sort, enable -aU, disable -lsto
--format=WORDacross -x, commas -m, horizontal -x, long -l,
single-column -1, verbose -l, vertical -C
-G--no-groupinhibit display of group information
-g(ignored)
-I--ignore=PATTERNdo not list implied entries matching shell PATTERN
-i--inodeprint index number of each file
-k--kilobytesuse 1024 blocks, not 512 despite POSIXLY_CORRECT
-L--dereferencelist entries pointed to by symbolic links
-luse a long listing format
-mfill width with a comma separated list of entries
-N--literaldo not quote entry names
-n--numeric-uid-gidlist numeric UIDs and GIDs instead of names
-o--color,--colour colorize entries according to type
--colo(u)r=WORDyes -o, no, tty (if output is a terminal)
-pappend a character for typing each entry
-Q--quote-nameenclose entry names in double quotes
-q--hide-control-charsprint ? instead of non graphic characters
-R--recursivelist subdirectories recursively
-r--reversereverse order while sorting
-Ssort by file size
-s--sizeprint block size of each file
--sort=WORDctime -c, extension -X, none -U, size -S,
status -c, time -t
--time=WORDatime -u, access -u, use -u
-T--tabsize=COLSassume tab stops at each COLS instead of 8
-tsort by modification time; with -l: show mtime
-Udo not sort; list entries in directory order
-usort by last access time; with -l: show atime
-w--width=COLSassume screen width instead of current value
-xlist entries by lines instead of by columns
-Xsort alphabetically by entry extension
-1list one file per line
--helpdisplay this help and exit
--versionoutput version information and exit

While the traditional Unix ls had a smaller handful of options and a single-line usage message. Oh, and no --color-ls option

Guess which one I prefer? And at 766 lines, it's a small enough bit of code to write and do some trivial tests on in about a week.

It's still tossed into the Mastodon-next source scrapbox, of course (with bits of /bin and libc just sort of flung in there willy-nilly), but having a bit pile of random new code will be a subtle encouragement for working on the packaging system. And in the meantime, I've got a new ls that I can hurl, with great force, at the modern Linux systems I develop on at work and get rid of at least one of the offensive syntax-coloring "enhancements" that makes a modern Unix a less-inviting programming environment.