How to keep from duplicating path variable in csh

前端 未结 12 769
我在风中等你
我在风中等你 2020-11-27 05:19

It is typical to have something like this in your cshrc file for setting the path:

set path = ( . $otherpath $path )

but, the path gets dup

12条回答
  •  有刺的猬
    2020-11-27 05:56

    dr_peper,

    I usually prefer to stick to scripting capabilities of the shell I am living in. Makes it more portable. So, I liked your solution using csh scripting. I just extended it to work on per dir in the localdirs to make it work for myself.

    foreach dir ( $localdirs )
        echo ${path} | egrep -i "$dir" >& /dev/null
        if ($status != 0) then
            set path = ( $dir $path )
        endif
    end
    

提交回复
热议问题