Search code examples
solariscsh

csh script inherit envirionment variables?


I found an odd problem when I run a simple csh script on Solaris.

#!/bin/csh
echo $LD_LIBRARY_PATH

Let's call this script test. When I run this:

shell> echo $LD_LIBRARY_PATH
shell> /usr/lib:/usr/openwin/lib:/usr/dt/lib:/usr/local/lib:/lib:/my_app/lib
shell> ./test
shell> /usr/lib:/usr/openwin/lib:/usr/dt/lib:/usr/local/lib:/lib

They print out totally different values for $LD_LIBRARY_PATH. I can't figure out why. (It's OK on my linux machine)

Thanks!


Solution

  • Do you set $LD_LIBRARY_PATH in your $HOME/.cshrc?

    You really shouldn't if you do, since it often just breaks software, but changing the first line of the script to #!/bin/csh -f will cause your script to not read .cshrc files at the start, protecting you from other users who made that mistake.