求助一个很简单的shell脚本
发表于 : 2012-11-18 15:29
请问如何判断gcc -g -Wall g.c -lm -o g这个语句当有提示时即g.c这个源文件里有错误时为真,无提示即g.c源文件编译正确为假??
代码: 全选
$gcc -g -Wall g.c -lm -o g
$echo $?
0
$sed -i 's/^\(int main\)/\/\/\1/g' g.c
$gcc -g -Wall g.c -lm -o g
g.c:3:1: 錯誤:expected identifier or 「(」 before 「{」 token
$echo $?
1