ARM shell 文件出错:bash: setup.csh: 行 48: 语法异常: 未预期的文件结尾

ARM shell 文件出错:-bash: setup.csh: 行 48: 语法错误: 未预期的文件结尾
#!/bin/csh

# Guard the script against execution - it must be sourced!

# when sourcing: on csh $0 is not set, for tcsh it's set to /bin/tcsh
# when executing it's the name of this script

if ( $?0 ) then
echo $0 | egrep 'setup.csh|setup_all.csh|source_me.csh|source_all.csh' > /dev/null
if ( $status == 0 ) then
echo ""
echo "ERROR: the setup file must be SOURCED, NOT EXECUTED in a shell."
echo "Try: source setup.csh"
echo ""
exit 1
endif
endif

# this line is modified by the ./install.sh script which must be executed once before the setup scripts can be sourced
set DIR="/home/qwm/ARM/FastModelsPortfolio_9.4"

if ( "$DIR" == "error" ) then

echo "please execute (not source) the file install.sh in the same directory as setup.csh first"
echo "(this has to be done only once)"

else

setenv PVLIB_HOME "$DIR"

if ( -e "$PVLIB_HOME/etc/license.csh" ) then
    source "$PVLIB_HOME/etc/license.csh"
endif

if ( ! $?PYTHONPATH ) then
    setenv PYTHONPATH "${PVLIB_HOME}/lib/python2.7"
else if ( "$PYTHONPATH" == "" ) then
    setenv PYTHONPATH "${PVLIB_HOME}/lib/python2.7"
else
    setenv PYTHONPATH "${PYTHONPATH}:${PVLIB_HOME}/lib/python2.7"
endif

echo "setting PVLIB_HOME to $PVLIB_HOME"
echo "setting PYTHONPATH to $PYTHONPATH"

endif
------解决思路----------------------
说错了,是csh,不是zsh。

如果楼主没有csh的话,把这个csh脚本改成bash脚本一样能用。

主要区别
1. arithmetic expression, 即if的条件部分,csh用(), bash用(( ))
2. 复制,csh用set,bash用=(等号)
3. 环境变量,csh用setenv,bash用export