The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-21-2008
benwj benwj is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 1
Why does set also change setenv variables?

I thought that set and setenv was easy enough to understand until I started experimenting.
I noticed the same problem in a previous thread, so I will use it as an example.

set command gave the following output:

argv ()
cwd /homes/e/ee325328/assignment.2
home /homes/e/ee325328
path ( a whole bunch of paths)
prompt sol%
shell /bin/csh
status 0
term ansi
user ee325328

setenv command gave the following output:

HOME=/homes/e/ee325328
PATH=bla bla
LOGNAME=ee325328
_INIT_PREV_LEVEL=S
_INIT_RUN_LEVEL=3
_INIT_RUN_NPREV=0
_INIT_UTS_ISA=sparc
_INIT_UTS_MACHINE=sun4d
_INIT_UTS_NODENAME=sol
_INIT_UTS_PLATFORM=SUNW, SPARCserver-1000
_INIT_UTS_RELEASE=5.7
_INIT_UTS_SYSNAME=SunOS
_INIT_UTS_VERSION=Generic_106541-19
PWD=/homes/e/ee325328/assignment.2
USER=ee325328
OPENWINHOME=/usr/openwin

The following variables are common to both:
HOME
PATH
USER
(but they are lower case for set and uppercase for setenv)
When using the set command to change any of these, the setenv values are also affected, and vice versa.

How is a variable common to the shell and the environment created?

I tried creating a shell variable and an environment variable of the same name, but their values can be changed independently.
Which leads to another question: If the value is different, which one takes precidence?
Better stop and try and undertand what's going on before going any further.