[comp.unix.questions] export vars from cshell script?

heidi@kiwi.bcm.tmc.edu (Heidi Johnson) (11/15/89)

Hello,

Is there an equivalent in the Cshell to the Bourne shell's export
facility?  We have would like to define new environment variables in a
shell, and have them be known to subsequent processes.

We're using SunOS 4.0.

Thanks a million,

Heidi Johnson
heidi@kiwi.bcm.tmc.edu

ron@woan.austin.ibm.com (Ronald S. Woan) (11/15/89)

In article <1815@gazette.bcm.tmc.edu>, heidi@kiwi.bcm.tmc.edu (Heidi 
writes:
> Is there an equivalent in the Cshell to the Bourne shell's export
> facility?  We have would like to define new environment variables in a
> shell, and have them be known to subsequent processes.

I may be way off base, but I have always been under the impression that
setenv automatically exported them??!!

							Ron
+-----All Views Expressed Are My Own And Are Not Necessarily Shared By------+
+------------------------------My Employer----------------------------------+
+ Ronald S. Woan  (IBM VNET)WOAN AT AUSTIN, (AUSTIN)ron@woan.austin.ibm.com +
+ outside of IBM       @cs.utexas.edu:ibmaus!auschs!woan.austin.ibm.com!ron +
+ last resort                                        woan@peyote.cactus.org +

exspes@gdr.bath.ac.uk (P E Smee) (11/16/89)

In article <1815@gazette.bcm.tmc.edu> heidi@kiwi.bcm.tmc.edu (Heidi Johnson) writes:
>Is there an equivalent in the Cshell to the Bourne shell's export
>facility?  We have would like to define new environment variables in a
>shell, and have them be known to subsequent processes.
>
>We're using SunOS 4.0.

Use setenv.  (See csh(1)).

Variables defined using setenv are available in child processes.  The
syntax of setenv is different from set, God only knows why.  Look also
at the 'Variable substitutions' section in csh(1), as there are
limitations on the use of : modifiers if a variable is an environment
var rather than a shell (set) var.  If you have the same name both
'set' and 'setenv'ed in a process, the 'set' definition should win.
(So, if you need to use : modifiers on env'ed vars, you need to arrange
for the child process to do something like:

set fred $fred

(Assuming fred is not already 'set', the 'setenv' value will be picked up.)

-- 
 Paul Smee               |    JANET: Smee@uk.ac.bristol
 Computer Centre         |   BITNET: Smee%uk.ac.bristol@ukacrl.bitnet
 University of Bristol   | Internet: Smee%uk.ac.bristol@nsfnet-relay.ac.uk
 (Phone: +44 272 303132) |     UUCP: ...!uunet!ukc!gdr.bath.ac.uk!exspes

exspes@gdr.bath.ac.uk (P E Smee) (11/16/89)

In article <869@awdprime.UUCP> @cs.utexas.edu:ibmaus!auschs!woan.austin.ibm.com!ron writes:
>In article <1815@gazette.bcm.tmc.edu>, heidi@kiwi.bcm.tmc.edu (Heidi 
>writes:
>> Is there an equivalent in the Cshell to the Bourne shell's export
>> facility?  We have would like to define new environment variables in a
>> shell, and have them be known to subsequent processes.
>
>I may be way off base, but I have always been under the impression that
>setenv automatically exported them??!!

Sposed to do, yep.  Problem is that people who are just moving to csh
from sh tend to overlook 'setenv', because csh also has 'set' which
looks at first glance like it ought to be equivalent to sh 'set'.
(In fact, I suppose it is.  It's the fact that csh lacks 'export' which
is critical, and which is what they notice.)

-- 
 Paul Smee               |    JANET: Smee@uk.ac.bristol
 Computer Centre         |   BITNET: Smee%uk.ac.bristol@ukacrl.bitnet
 University of Bristol   | Internet: Smee%uk.ac.bristol@nsfnet-relay.ac.uk
 (Phone: +44 272 303132) |     UUCP: ...!uunet!ukc!gdr.bath.ac.uk!exspes

exspes@gdr.bath.ac.uk (P E Smee) (11/16/89)

In article <1989Nov16.110451.10002@gdt.bath.ac.uk> exspes@gdr.bath.ac.uk (P E Smee) writes:
>(So, if you need to use : modifiers on env'ed vars, you need to arrange
>for the child process to do something like:
>
>set fred $fred
>
Oops, that should, of course, be:

set fred=$fred

-- 
 Paul Smee               |    JANET: Smee@uk.ac.bristol
 Computer Centre         |   BITNET: Smee%uk.ac.bristol@ukacrl.bitnet
 University of Bristol   | Internet: Smee%uk.ac.bristol@nsfnet-relay.ac.uk
 (Phone: +44 272 303132) |     UUCP: ...!uunet!ukc!gdr.bath.ac.uk!exspes

perry@ccssrv.UUCP (Perry Hutchison) (11/17/89)

In article <1815@gazette.bcm.tmc.edu> heidi@kiwi.bcm.tmc.edu (Heidi Johnson)
writes:

>Is there an equivalent in the Cshell to the Bourne shell's export
>facility?  We have would like to define new environment variables in a
>shell, and have them be known to subsequent processes.

There is not an exact equivalent, but similar functionality is available.
In Bourne shell, all variables are set with "=" and those which are to be
placed in the environment are "export"ed.  In C shell, variables created
with "setenv" are placed in the environment while those created with "set"
are private.