0

我正在尝试修改 OSX 中的 .tcshrc 文件以包含用于安装 GNURadio 的 shell 环境变量。但是,它返回给我这样的错误消息

“-bash:/Users/admin/.tcshrc:第 22 行:语法错误:文件意外结束”

修改后的tcshrc文件如下

 if (-r /opt/local/bin/port) then
      setenv LDFLAGS "-L/opt/local/lib ${LDFLAGS}"
      setenv PATH ${HOME}/bin:/opt/local/bin:/opt/local/sbin:${PATH}
      setenv MANPATH /opt/local/share/man:${MANPATH}
      setenv INFOPATH /opt/local/share/info:${INFOPATH}
      setenv PKG_CONFIG_PATH /opt/local/lib/pkgconfig:${PKG_CONFIG_PATH}
  endif

  # Gnuradio source directory (set up for installing gnuradio in $GR/local/)
  setenv GR $HOME/gnuradio
  setenv GR_INSTALL ${GR}/local
  setenv LDFLAGS "-L${GR_INSTALL}/lib ${LDFLAGS}"
  setenv PKG_CONFIG_PATH ${GR_INSTALL}/lib/pkgconfig:${PKG_CONFIG_PATH}
  setenv DYLD_LIBRARY_PATH ${GR_INSTALL}/lib:${DYLD_LIBRARY_PATH}

  # Set up PYTHON variables
  setenv PYTHON_CMD python
  setenv PYTHON_VERSION `${PYTHON_CMD} -V |& sed -e 's@\.@ @2' | awk '{ print $2 }'`
  setenv PYTHON_ROOT `which ${PYTHON_CMD} | sed -e s@/bin/${PYTHON_CMD}@@g`
  setenv PYTHONPATH ${GR_INSTALL}/lib/python${PYTHON_VERSION}/site-packages:${PYTHON_ROOT}/lib/python${PYTHON_VERSION}/site-packages

非常感谢您的帮助

4

1 回答 1

1

您希望 BASH 读取和处理一组用于不同 shell 的指令!TCSH 有一种类似 c 的编程语言,而 BASH 和 SH 使用一些类似 ALGOL-68 的模式(我认为)。Bash 根本无法处理您的脚本。

为您的 schript (tcsh/csh) 使用正确的 shell 或将您的脚本重写为 bash 语法。

if [ -r /opt/local/bin/port ]
  then
      export LDFLAGS="-L/opt/local/lib ${LDFLAGS}"
      export PATH=${HOME}/bin:/opt/local/bin:/opt/local/sbin:${PATH}
      export MANPATH=/opt/local/share/man:${MANPATH}
      export INFOPATH=/opt/local/share/info:${INFOPATH}
      export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig:${PKG_CONFIG_PATH}
  fi

  # Gnuradio source directory (set up for installing gnuradio in $GR/local/)
  export GR=$HOME/gnuradio
  export GR_INSTALL=${GR}/local
  export LDFLAGS="-L${GR_INSTALL}/lib ${LDFLAGS}"
  export PKG_CONFIG_PATH=${GR_INSTALL}/lib/pkgconfig:${PKG_CONFIG_PATH}
  export DYLD_LIBRARY_PATH=${GR_INSTALL}/lib:${DYLD_LIBRARY_PATH}

  # Set up PYTHON variables
  export PYTHON_CMD=python
  export PYTHON_VERSION=`${PYTHON_CMD} -V 2>&1 | sed -e 's@\.@ @2' | awk '{ print $2 }'`
  export PYTHON_ROOT=`which ${PYTHON_CMD} | sed -e s@/bin/${PYTHON_CMD}@@g`
  export PYTHONPATH=${GR_INSTALL}/lib/python${PYTHON_VERSION}/site-packages:${PYTHON_ROOT}/lib/python${PYTHON_VERSION}/site-packages
于 2012-06-06T12:19:32.247 回答