2016年3月4日 星期五

[Linux] How can I get what my main function has returned

Most shells store the exit code of the previous run command in $? so you can store or display it.
$ ./a.out
$ echo $?     # note - after this command $? contains the exit code of echo!
or
$ ./a.out
$ exit_code=$?    # save the exit code in another shell variable.

沒有留言:

張貼留言