Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

On my office computer it seems like I've have two PATH variables.

$path : This is delimited by " " (Space)

$PATH : This is delimited by ":" (Colon)

Though when I update one, the other one gets updated as well. Is this the normal behavior in Linux or is there something wierd going on in my machine?

Should I keep them both, or delete one of them?

Edit: I'm using csh, I found this because some of my colleagues were updating the "path" variable, while others did it with "PATH". Though I deleted all occurences of updating "PATH" in my .cshrc, it still appears when I try to echo them.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

The real PATH variable is the uppercase one, except in (t)csh itself where it's a little more complicated.

PATH is an environment variable, which all applications (not just shell) look up to invoke a program by name. The value of PATH is a string listing directory names separated by colons.

As a convenience, csh also provides a variable called path. The value of this variable is a list of strings, each string being a directory name. Whenever you set path, csh automatically sets PATH to the concatenation of the elements of path with : between elements.

If you set PATH with set, path is unaffected. Furthermore, csh set the PATH environment variable to match its path internal variable, so set PATH=... has no practical effect.

If you set PATH with setenv, path is updated accordingly. However setenv PATH … does not affect what $PATH expands to, which makes it awkward to use.

The upshot is that in csh, you should stick with path. But everywhere else PATH is the only one you'll see.

share|improve this answer
    
I should probably switch to BASH :D –  Kartik Anand Mar 6 at 5:27
    
@KartikAnand zsh! (Which also has both path and PATH, but there it's less confusing because there isn't the shell/environment variable (set/setenv) distinction: in zsh, if you set PATH in any way, path is updated and vice versa.) –  Gilles Mar 6 at 9:53
    
will sure do!! Anyways why doesn't zsh need both environment and shell variables? I thought that was necessary. –  Kartik Anand Mar 6 at 10:29
    
@KartikAnand In Bourne-style shells (sh, ash, bash, ksh, zsh, …), environment variables are automatically shell variables with the same value. A shell variable is either exported (in which case it's also an environment variable, with the same value), or not (in which case there is no environment variable by the same name). This simplifies matters somewhat. –  Gilles Mar 6 at 19:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.