hi i'am not really fluent in bash shell script, i'am doing some compilation using gcc that executed by bash script, how do I know (check) if the compilation was successful or not? any example?
Since you are doing this in a script, you could alternatively check the exit code of the commands as you run with the
You could do something like:
./configure if [ $? -ne 0 ] then echo Configure failed exit 1 fi make if [ $? -ne 0 ] then echo make failed exit 1 fi make install if [ $? -ne 0 ] then echo make install failed exit 1 fi echo All steps Succeeded
Personally I tend to be more verbose and use longer forms in scripts because you never know who will be maintaining it in the future.
If it was a one off command line run i would use the method that Dennis and mibus have already mentioned
Your question stated "compilation using gcc", but I see in your comment that you're actually using
make. That should have been specified in your question.
You can use the same technique that mibus showed.
./configure foo && make && make install && echo OK
This will not proceed to the next step unless the previous one completed successfully and if all goes well it will print "OK".