检查在bash脚本C程序的返回值? [英] Checking the return value of a C program in a bash script?

查看:104
本文介绍了检查在bash脚本C程序的返回值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个bash脚本中,我使用$检查最后一次运行一个命令的退出code?可变的,但现在我执行一个C程序(从脚本),如果该计划得到成功执行返回0。有什么办法,我可以从我的bash脚本赶上的C程序这个返回值?

I have a bash script in which i check the exit code of a last run command by using $? variable but now I am executing a C program (from that script) which returns 0 if the program gets executed successfully. Is there any way I can catch this return value of the C program from with in my bash script?

相信喜欢AWK不同的命令,SED等都是用C写的他们怎么使用$?存储他们的退出codeS里呢?我怎样才能让我的C程序存储在$ ??其退出code

I believe different commands like awk, sed etc are written in C. How do they use $? to store their exit codes in it? How can I make my C program to store its exit code in $??

我希望我的问题是清楚的。

I hope my question is clear.

推荐答案

有没有必要做任何事情 - 如果你的C程序返回0,这就是将存储在 $ 的执行它的外壳变量。

There's no need to do anything - if your C program returns 0, that's what will be stored in the $? variable of the shell that executed it.

这篇关于检查在bash脚本C程序的返回值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆