osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

The "loop and a half"


On 06/10/2017 12:45, Chris Angelico wrote:
> On Fri, Oct 6, 2017 at 9:32 PM, bartc <bc at freeuk.com> wrote:
>> (And properly, by being given the same of an actual file rather than using
>> crude redirection.)
> 
> Why do you call redirection "crude"? Do you not understand the value
> of generic solutions that work with all programs, rather than having
> every program implement its own "take input from file" parameter?
> 
> You can disagree with the Unix philosophy all you like, but when you
> insult it, you just make yourself look like an idiot.

Redirection is used on Windows too. I use output redirection quite 
frequently (to capture the output of 'dir' for example).

I don't rely on > and < in my own programs. Where there's complex, mixed 
output, the bulk of it - the data - needs to go to a proper file, while 
the screen shows messages.

If you don't like the word 'crude', try 'lazy'. Take this example of the 
gcc C compiler:

  > gcc -E program.c

This preprocesses the code and shows the result. Typical programs will 
have many thousands of lines of output, but it just dumps it to the 
console. You /have/ to use '>' to use it practically (Windows doesn't 
really have a working '|' system.)

Another compiler might simply write the output to a file 'program.i'.

BTW if I try:

  > gcc <program.c

it doesn't work (this on Linux). What happened to the generic solution?

-- 
bartc