difference between shell variable and environment variable

difference between shell variable and environment variable

Post by Ramprasad A Padmanabha » Sun, 05 Jan 2003 18:21:37



Hello all,

  I can set a shell var by using
        set name1=value
  I can set an env variable by using
        set name2 value

What is the difference between name1 and name2

--
Ramprasad A Padmanabhan
Sr Software Engineer
Netcore Solns Pvt Ltd
Mumbai
ph - (022) 4628000

 
 
 

difference between shell variable and environment variable

Post by John » Sun, 05 Jan 2003 19:11:32



Quote:> Hello all,

>   I can set a shell var by using
>         set name1=value
>   I can set an env variable by using
>         set name2 value

> What is the difference between name1 and name2

name1 is available to the shell.
name2 is also passed by the shell to any programs it runs as
part of their "environment". Whether these programs make any
use of these environment variables (and, for that matter, whether
they are even able to) is another question entirely.

Presumably you are using the C shell or a derivative like tcsh?
There are lots of different shells, and they have different syntax(es).
Shells belong in two major families:
    1) C-shell, tcsh
    2) Bourne shell, sh, bash, ksh (Korn shell)
And there are others. If you have shell problems that you post here,
it often helps if you let us know which shell (and which operating
system) you are using.

In Bourne shells, you would "export" name2 rather than "setenv" it.

John.