Environment variables and the mac terminal

AUser

Registered
Hello,

Quick question that has me a little confused

why do i get the following output:

myapple:~ user$ echo $MYENVVAR
someval
myapple:~ user$ cat test
echo $MYENVVAR
myapple:~ user$ ./test

myapple:~ user$


Shouldn't the test script echo "someval"?

why is the enviroment variable in the shell not being passed to the script that is executing? Obviously not, as this is not what is happening....

This is causing me all sorts of headaches trying to compile software that requires external enviroment variables!

Does anyone know why it is that this doesn't behave as i expected?

Thanks
 
Sorry, but I have run a test file containing "echo $PATH" and it has worked perfectly both in bash and tcsh.
Perhaps some configuration parameter in your shell is creating the problem?
 
For bash, make sure that you export your defined environment variables, otherwise your sub-processes won't inherit them. Either

MYENVVAR=someval
export MYENVVAR

or

export MYENVVAR=someval

will do the trick.
 
looks like the environment is seeing 'sample' settings. try opening a terminal window and type

rm .profile


that will remove your bash profile. close the terminal window and then open another. type

env

the paths will be set to their defaults.
 
Back
Top