方便的 shell function:
pathmunge () { if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi fi export PATH }
在設定路徑之前建立這個函式,就可以避免路徑裡出現重複的項目;加以變化,還可以設定其它種類的路徑:
manpathmunge () { if ! echo $MANPATH | /bin/egrep -q "(^|:)$1($|:)" ; then if [ "$2" = "after" ] ; then MANPATH=$MANPATH:$1 else MANPATH=$1:$MANPATH fi fi export MANPATH }
不知道 Debian 的 /etc/bashrc 裡為何沒有定義。把這個函式加到 ~/.bashrc 裡的話會很方便。
Posted by yungyuc
at 20:45,
0 comment,
0 trackback.
Navigate
- Previous: 中文;粗體 @2005/09/20
- Next: SCons 裡的 Fortran 90 @2005/09/23
Add a trackback
Please send trackback to: http://blog.seety.org/everydaywork/2005/9/23/403/trackback/.
Add a comment