Path – Which is the Real PATH Variable in csh?

cshpath

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 weird 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 occurrences of updating PATH in my .cshrc, it still appears when I try to echo them.

Best Answer

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.

Related Question