Compile several projects (with makefile), but stop on first broken build?

前端 未结 2 1359
一个人的身影
一个人的身影 2020-12-29 17:04

I want to do something like:

for i in *
do
    if test -d $i
    then
        cd $i; make clean; make; cd -;
    fi;
done

And this

2条回答
  •  失恋的感觉
    2020-12-29 17:34

    You can check whether the make has exited successfully by examining its exit code via the $? variable, and then have a break statement:

    ...
    make
    
    if [ $? -ne 0 ]; then
        break
    fi
    

提交回复
热议问题