SUMMARY: .cshrc syntax help

From: Karen R McArthur (kmcarthu@bates.edu)
Date: Fri Jan 30 2004 - 11:16:05 EST


Kudos to Paul Sand, Stephen Feehan, Tim Cutts, Bob Harris and Dr Blinn.
All of them sent me working solutions to this problem! Thank you very
much. I used Dr Blinn's solution with 1 change: I added -e'^\.:' to the
grep.

Here's Dr Blinn's reply:

I would try something like

echo $PATH | grep -q -e ':\.:' -e ':\.$' && echo there

or in your script,

echo $PATH | grep -q -e ':\.:' -e ':\.$' || set path="$path ."

Note that in the C shell there is a BIG difference between the
standard environment variable PATH and the C shell specific
variable "path". If you want to manipulate PATH directly,
you'd need something like this:

echo $PATH | grep -q -e ':\.:' -e ':\.$' || setenv PATH "$PATH:."

Try echo $PATH and echo $path and notice the differmints..

Tom

Karen R McArthur wrote:

> I'd like to add an if statement to our .cshrc or .login file, but I'm
> having problems with the syntax. Could someone help?
>
> If the "dot" entry does not exist in the $PATH variable, append it to
> the $PATH variable. Sounds simple enough, huh? I've tried the
> following and many permutations of it ... any help would be appreciated.
>
> if ( ${PATH} !~ *\.* ) then
> set PATH=($PATH .)
> endif
>





This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:49:50 EDT