[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: setenv
Shlomi Fish wrote:
>
> Well, just a note, in sh-like shells (such as GNU bash) you simply use the "VAR=VALUE" command.For example, to assign the value "Hello" to the environment variable MYVAR type the following line:
> MYVAR=Hello
>
> One of the big differences between csh (C-Shell) and sh (Bourne shell) like shells is that sh uses the environment variables as program variables, while csh keeps its own separate set of variables (which are set by "SET VAR=VAL"). However, in order to pass values to a child shell script I think one needs to use the setenv/getenv syntax.
>
> BTW, I always wondered if it's possible to write a program or a script that will set one of the environment variables in the parent process (i.e. the shell that executes it). Since I now realize that all the shells use built-in commands in order to modify the environment variables, maybe it isn't possible as I thought.
>
> Shlomi Fish
>
>
first: on Bourne shell you have to use EXPORT
second: to pass a variable in tcsh to a parent shell, you have to run the chiled shell as source
i.e.
parent : #! /bin/csh
source child
echo $VAR
exit 0
child : #! /bin/csh
setnv VAR "hi parent"
exit 0
top shell:
~/scripts> parent
hi parent
~/scripts>
Regards
Erez.