Comment by ⛵️ dsp
i got used to using du for traversing a dirent. i know that disk usage doesn't sound like the right name of a command for that. in the plan9 mailing lists i believe to have seem more than once the need for an abstracted command to walk a tree in order to capture what -R or du are doing here. i guess this paired with stat in some cases (cause you might be walking a VFS where stat almost makes no sense) and something to do the presentation is what could be the parts of ls you are talking about.
Jan 13 · 4 months ago
2 Later Comments ↓
This is a tricky problem. In most Unix-like systems, the only character that cannot appear anywhere in a path is NUL. Therefore, NUL is the only character that could unambiguously separate paths in a listing. However, NUL is also used to terminate strings in C, so most POSIX utilities have undefined or unspecified behavor upon encountering it. Usually, they either strip the NULs or give an error.
It's a double-edged sword: by nature, a tool that could list any possible set of paths perfectly couldn't have its output processed as text by other tools, because the only entry separator that works perfectly is usually not allowed in text. I wouldn't be surprised if that's why `ls` was designed the way it was in the first place.
Other alternatives are binary formats, such as DER or SDSER formats. (In my idea of operating system design it does use something similar, rather than only text output; it is possible to make programs that do something similar on UNIX as well (although it is not quite the same, but can be similar).)
Original Post
— spell.mywire.org:1960/~stack/0257.gmi
ls but The Unix Way — Where I build a composable ls toy...