功能:tcsh中,如果PATH中不存在路径,则为PATH添加新路径,反之不添加
#! /bin/tcsh
# learn.tcsh
# -d 目录是否存在
# \!:1 表示第1个参数
# \!:2* 表示第2个参数以及余下的所有参数
# \!* 表示所有参数
# =~ 约等于
# \!= 不约等于
# basic learn test
alias test 'if(-d \!:1) echo "yes"; if(! -d \!:1) echo "no"'
# test /bin
# yes
# test aa
# no
alias test2 'echo "\!:1 - \!:2 - \!*"'
# test2 a b c
# a - b c - a b c
alias test3 'if("\!:1" =~ *"\!:2"*) echo "yes"; if("\!:1" \!~ *"\!:2"*) echo "no"'
# test3 a a:b
# no
# test3 a:b a
# yes
# prepend/append $arg[1] to $argv if $argv[1] not exit in $argv[0]
alias prepend 'if (-d \!:2) if ("$\!:1" \!~ *"\!:2"*) setenv \!:1 "\!:2":${\!:1}'
alias append 'if (-d \!:2) if ("$\!:1" \!~ *"\!:2"*) setenv \!:1 ${\!:1}:\!:2'