2
你可以幫助給算法用於生成$?從程序退出代碼殼?例如,
$? is 1 for exit(1);
$? is 255 for exit(-1);
所以我可以從$推斷退出代碼?
$? is 1 => exit code is 1
$? is 255 => exit code is -1
一些特別的東西,
$? is 0 for exit(256);
$? is 1 for exit(257);
誰能給用於生成$殼的算法?帶退出碼,這樣我就可以知道退出碼只能通過觀察$?執行命令後執行。
非常感謝。
編輯:爲了回答下面的問題,我添加了這個例子。
----a.c----
1 #include <stdlib.h>
2 int main()
3 {
4 exit(-1);
5 }
[email protected]:~/work/02_test/ctest> gcc a.c
[email protected]:~/work/02_test/ctest> ./a.out
[email protected]:~/work/02_test/ctest> echo $?
255
[email protected]:~/work/02_test/ctest>
返回類型是一個uint8_t –
感謝您的澄清;更新瞭解釋-1和256.沒有算法,只有一個8位返回值。 –