9 ms·
Doesn't `ls` behaves like this, printing in multiple columns when the output is a tty?
by vinc 7y ago
Doesn't `ls` behaves like this, printing in multiple columns when the output is a tty?
- majewsky 7y agoIt does, but it can be argued that this is not in response to a certain type of output file. ls(1) formats filename lists into columns depending on the width of the output viewport. It just so happens that it's not able to determine that width for anything but tty devices, so it falls back to the safe default "single column". To use an analogy from web browsers, the equivaleny guideline would be asking websites not to detect features by reading the User-Agent, and using feature detection instead.
- duckerude 7y agoNowadays it also adds quotes to filenames with spaces or special characters if the output is a terminal, to make copying and pasting easier.
- smorrow 7y agoWhen I first started using Plan 9 I thought it was great how it (ls)'d give results the same way you asked for them, i.e. if (cd a; ls) would print 'f' then (ls a) would print 'a/f'.