linux - 这个shell脚本有什么错误

标签 linux shell unix

我写了下面的代码..

installFunction(){

    perl Makefile.PL
    flag1 = $?

    make    
    flag2 = $?

    make install
    flag3 = $?

    make test
    flag4 = $?

    cd ..


    return $flag1 || $flag2 || $flag3 || $flag4
}
if(installFunction != 0)
    then
        echo "installation failure"
        exit
fi  

但是当我运行代码时,出现以下错误

./install: 53: flag1: not found

./install: 53: flag2: not found

./install: 53: flag3: not found

./install: 53: flag4: not found

谁能说说是什么问题?

提前致谢!

最佳答案

尝试

flag1=$?

注意缺少空格。

http://tldp.org/LDP/abs/html/varassignment.html


正如 kev 提到的,您的 if 语句无效。

installFunction
if [ $? -ne 0 ]
then
        echo "installation failure"
        exit
fi

应该可以。必填链接:http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html

关于linux - 这个shell脚本有什么错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9662265/

相关文章:

c++ - 被信号中断的系统调用仍需完成

c++ - 在 linux 上加载多个相似的共享库

bash - 使用 bash 破坏一串随机字符

c++ - 定时发送和接收同一数据包

Perl 未初始化警告

arrays - 在 bash v.3 中迭代数组

c++ - v8 hello world 示例链接错误

linux - 从手机接收实时数据

linux - 通过全局ip连接到VPN连接的计算机

php - * 无法打开 vchiq 实例