How does commands like 'ls'ls know what its stdout is.?
It seems 'ls'ls is operating different depending on what the target stdout is, for. For example if iI do:
ls /home/matt/tmp
ls /home/matt/tmpthe result is:
a.txt b.txt c.txt
howeverHowever if do I ls /home/matt/tmp | cat do
ls /home/matt/tmp | cat
the result is (i.e. new line per result):
a.txt
b.txt
c.txt
The process is passed a file descriptor 1 for stdout right? How does it determine how to format the result? Does the file descriptor reveal information?