Re: csh what is the path separator
From: Keith Thompson (kst-u_at_mib.org)
Date: 05/17/05
- Next message: Chris F.A. Johnson: "Re: catching last few lines of tail"
- Previous message: unixSPAM_at_zeouane.org: "catching last few lines of tail"
- In reply to: linq936_at_hotmail.com: "csh what is the path separator"
- Next in thread: Bill Marcum: "Re: csh what is the path separator"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 17 May 2005 21:20:12 GMT
linq936@hotmail.com writes:
> some example as,
>
> set path = (path1 path2 $path)
>
> and I see also this,
>
> set path = (path1:path2:$path)
>
> I think I am confused. And it seems $path and $PATH sometimes are
> different.
>
> What should be the correct then?
$PATH is an environment variable, not specific to any particular
shell. Its value is a single string, consisting of a series of
directory names separate by ':' characters. For example:
setenv PATH /usr/local/bin:/usr/bin:/bin
$path is a shell variable, specific to csh and tcsh. Its value is not
a single string; it's a list of strings, each of which is a directory
name. For example:
set path = ( /usr/local/bin /usr/bin /bin )
The $PATH environment variable and the $path shell variable are
"magically" tied together by the shell, so that modifying one
automatically changes the other. Setting $path to a list value
implicitly sets $PATH to a single string consisting of the elements of
$path joined with ':' characters. Setting $PATH implicitly sets $path
to a list determined by splitting the value of $PATH, using ':' as a
delimiter.
If you do this:
set path = ( /usr/local/bin:/usr/bin:/bin )
the result will be a valid value for $PATH, but an invalid vlaue for
$path. As it turns out, the shell uses $path when searching for
commands, so unless you actually have a directory named
"/usr/local/bin:/usr/bin:/bin", you won't be able to do much. Your
shell will be in an inconsistent state. You can fix it like this:
setenv PATH $PATH
which forces the shell to reinitialize $path, but you should really
just avoid this situation in the first place. If you only set $path
to a list value, and/or only set $PATH to a string with ':'
delimiters, you don't need to care about ugly details.
"man csh" for more information.
-- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this.
- Next message: Chris F.A. Johnson: "Re: catching last few lines of tail"
- Previous message: unixSPAM_at_zeouane.org: "catching last few lines of tail"
- In reply to: linq936_at_hotmail.com: "csh what is the path separator"
- Next in thread: Bill Marcum: "Re: csh what is the path separator"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|