4 ms·
>> "ls" is oriented for human viewing, not composition with other tools. > Is there any basis for this claim? Of course. For starters, there's the fact that
by emmelaich 10y ago
>> "ls" is oriented for human viewing, not composition with other tools.
> Is there any basis for this claim?
Of course. For starters, there's the fact that the date modified column format depends on how long in the past it was modified! This makes it impossible for `sort` to work with.
So suggesting that the `-t` option of `ls` could be removed in favour of using `sort` is entirely wrong.
I could go on and on. There are excellent criticisms of UNIX/Linux. This is not one.
- anon1385 10y ago>there's the fact that the date modified column format depends on how long in the past it was modified! Not if you do the sane thing and use the -T option. Of course that requires the user to read another huge man page to find out that such an option exists. I think you have failed to understand the kind of alternative people are proposing. Nobody is saying that the current ls sorting flags should be removed and replaced by passing the output of the current ls command to sort. That would be broken and difficult to use for all the usual reasons that passing around unstructured text is broken and difficult. The idea is passing more structured data between processes so that the problem you describe could never even happen. What you describe is actually the type of issue people want to solve (but in the general case, not just for ls). Formatting data for humans to read and formatting data for machines to read are different problems. Current unix cli tools have to attempt to do both, which often means doing neither well. If you are lucky there are at least some flags you can use to make the output more structured. If you are unlucky the command magically reformats the output based on the type of device it's printing to.
- boomlinde 10y agoI think that you are confusing my argument with another one. I'm not in the "ls should only list files" camp. I'm merely questioning the idea that it isn't oriented towards composability on the basis that even the more featureful implementations revert to a simple filename-newline format that's perfect for stream editing or grepping when their output isn't a TTY. If history is anything to go by this is not an unintended side effect, which would suggest that ls is oriented towards composition, even if poorly and unexclusively so.
- emmelaich 10y agoNah, Im not confusing your argument, I'm saying that the changing date format inhibits composability. The truth is that shell is partly composable but with many concessions for friendly interactive use. You could remove the compromises but it would not be much fun to use.