Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.bugs.usg Subject: Re: "tabs" and "tput" assume TERM is set Message-ID: <2526@sun.uucp> Date: Tue, 30-Jul-85 21:17:23 EDT Article-I.D.: sun.2526 Posted: Tue Jul 30 21:17:23 1985 Date-Received: Fri, 2-Aug-85 06:30:38 EDT References: <2484@sun.uucp> <2455@pegasus.UUCP> Distribution: net Organization: Sun Microsystems, Inc. Lines: 35 > In article <2484@sun.uucp> guy@sun.uucp (Guy Harris) writes: > >Both of them assume, at some point, that getenv("TERM") will never return a > >NULL. Regardless of whether the S5 Interface Definition says it'll always > >be set or not, it's really dumb to assume it'll never happen... (Also, > >"tput" didn't declare "getenv".) > > Actually, both of these programs pass that work on to setupterm() to notice > that getenv() may have returned a NULL. Setupterm() then handles it > gracefully. By handing an error code back to "tput", instead of printing a message. "Tput" then proceeds to print an error message using "getenv" *WITHOUT* checking for "getenv" being null. It should do this check if for no other reason than to give a meaningful error message: No such terminal: unknown (as "setupterm" would print if no error return were specified) or tput: unknown terminal "unknown" just won't do; TERM not specified in environment or some translation of that into a human language is required (so the user knows *why* the program is complaining and can correct the problem immediately, instead of having to call in a guru and engaging in a 5-minute dialogue the result of which is that the guru, rather annoyed by getting dragged in on a trivial matter like this, finally figures out that the guy didn't set TERM - or that the system can't do it for them). Since it has to call "getenv" anyway (unless a "-T" flag was specified), it might as well pass the result on to "setupterm" and save it the trouble. Guy Harris