Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!cwjcc!hal!ncoast!allbery From: allbery@ncoast.ORG (Brandon S. Allbery) Newsgroups: comp.unix.wizards Subject: Re: stdout (was What "isatty"?) Message-ID: <13692@ncoast.ORG> Date: 3 Jun 89 18:07:20 GMT References: <19756@adm.BRL.MIL> <17796@mimsy.UUCP> Reply-To: allbery@ncoast.UUCP (Brandon S. Allbery) Followup-To: comp.unix.wizards Organization: Cleveland Public Access UN*X, Cleveland, Oh Lines: 48 As quoted from <17796@mimsy.UUCP> by chris@mimsy.UUCP (Chris Torek): +--------------- | In some article whose referent is gone because Root Boy gets this stuff | via a mailing list rather than netnews, I wrote: | >>Programs that produce output should produce the output to stdout. | | In article <19756@adm.BRL.MIL> rbj@dsys.icst.nbs.gov (Root Boy Jim) writes: | >I agree completely, Chris. Now get cracking on `cc', so that | >`cc prog.c' writes to stdout instead of `a.out' :-) | | As you can see by the `:-)' sign, Jimmy C. is kidding. But there is | much truth in this. The C compiler should write to stdout, unless | there is some overriding reason that it cannot---and in fact, the +--------------- Just to be obnoxiously pedantic [ ;-) ]: "cc" doesn't write to a.out; "ld" does. This doesn't mean that "cc" and "ld" aren't atrociously implemented, however. The problem with "cc" is that it's a (supposedly) "smart" wrapper for the compiler, assembler, and linker; it knows about filename extensions so it can decide whether to pass something to /lib/ccom, as, or ld (and under System III and -- I hear -- SunOS4.0, it complains if it doesn't recognize the extension of a file). Yucch. If I want that, I'll use "make", where I can define the program to use as I see fit. I'd prefer that "cc" build the pipeline to cpp, ccom, and c2/optim/copt/ whatever-it's-called-on-system-xyzzy, then write the resulting assembly code to stdout; then the casual user can pipe that to "as", or let the Makefile deal with it (that being what "make" is for). "ld" is more similar to an archive maintenance utility than to a filter, but it could still do its seeking in a temporary file and write the resulting binary to stdout... and for a trivial (one object module, no libraries other than -lc) binary it could easily be modified to be used as "cc < foo.c | as | ld > foo". (If you want to use libraries, change that to "... | ld - -lbar > foo".) (For that matter, "ld" (and "cc") probably shouldn't have a shorthand notation for libraries. How about "LDPATH=/lib:/usr/lib:... export LDPATH"?) This is not only conceptually simpler and cleaner, but it exploits multiple processors without hackery. However, in the rush to get fancy "intuitive" user interfaces, little things like that don't get much shrift.... ++Brandon -- Brandon S. Allbery, moderator of comp.sources.misc allbery@ncoast.org uunet!hal.cwru.edu!ncoast!allbery ncoast!allbery@hal.cwru.edu Send comp.sources.misc submissions to comp-sources-misc@ NCoast Public Access UN*X - (216) 781-6201, 300/1200/2400 baud, login: makeuser