Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!rochester!bbn!papaya.bbn.com!rsalz From: rsalz@bbn.com (Richard Salz) Newsgroups: comp.unix.questions Subject: Re: Environment variables Message-ID: <159@papaya.bbn.com> Date: Wed, 26-Aug-87 00:18:16 EDT Article-I.D.: papaya.159 Posted: Wed Aug 26 00:18:16 1987 Date-Received: Thu, 27-Aug-87 07:15:58 EDT References: <626@unmvax.unm.edu> <2876@phri.UUCP> Reply-To: rsalz@bbn.com (Richard Salz) Organization: BBN Laboratories, Cambridge MA Lines: 30 Summary: Use $?xxxx The problem is in distinguishing between "set var value" and "setenv var value" -- in most cases, the C shell hides any difference between them -- $var will get the value of the "var" variable, be it a shell variable or an environment variable. With that caveat in mind: % if ( $?TERM ) echo TERM is set TERM is set % if ( $?FOO ) echo FOO is set % set FOO=yow % if ( $?FOO ) echo FOO is now set FOO is now set % if ( $?BAR ) echo BAR is set % setenv BAR value % if ( $?BAR ) echo BAR is now set BAR is now set Roy's idea of using printenv is probably better, but his method will probably cause quoting problems if you try to see if TERMCAP is set after using tset(1); this seems to do it: % if ( `printenv TERMCAP | wc -l` == 1 ) echo TERMCAP is set TERMCAP is set % if ( `printenv CAP | wc -l` == 1 ) echo CAP is set % Hope this helps, /r$ -- For comp.sources.unix stuff, mail to sources@uunet.uu.net.