shellÔõôÅжÏÏÂÁîÊÇ·ñÖ´ÐÐÀÖ³É
ÅÐ¶Ï shell ÏÂÁîÊÇ·ñÖ´ÐÐÀֳɣº¼ì²éÆäÍ˳ö״ֵ̬£¨exit status£©£¬Ê¹Óà $? ±äÁ¿»ñÈ¡Ç°Ò»¸öÏÂÁîµÄÍ˳ö״ֵ̬£¬Í˳ö״ֵ̬Ϊ 0 ÌåÏÖÏÂÁîÖ´ÐÐÀֳɣ¬·Ç 0 ÌåÏÖÏÂÁîÖ´ÐÐʧ°Ü¡£
ÔõÑùÅÐ¶Ï shell ÏÂÁîÊÇ·ñÖ´ÐÐÀÖ³É
ÅжÏÒªÁ죺
ÅÐ¶Ï shell ÏÂÁîÊÇ·ñÖ´ÐÐÀֳɣ¬×îÖ±½ÓµÄ·½·¨ÊǼì²éÆäÍ˳ö״ֵ̬£¨exit status£©¡£
»ñÈ¡Í˳ö״ֵ̬£º
¿ÉÒÔʹÓà $? ±äÁ¿»ñÈ¡Ç°Ò»¸öÏÂÁîµÄÍ˳ö״ֵ̬¡£
Í˳ö״ֵ̬¼ÄÒ壺
- 0£º ÏÂÁîÖ´ÐÐÀÖ³É
- ·Ç 0£º ÏÂÁîÖ´ÐÐʧ°Ü
¾ÙÀý£º
# Ö´ÐÐÏÂÁî²¢»ñÈ¡Í˳ö״ֵ̬ exit_status=$? # ƾ֤Í˳ö״ֵ̬ÅжÏÏÂÁîÊÇ·ñÖ´ÐÐÀÖ³É if [ $exit_status -eq 0 ]; then echo "ÏÂÁîÖ´ÐÐÀÖ³É" else echo "ÏÂÁîÖ´ÐÐʧ°Ü" fi
µÇ¼ºó¸´ÖÆ
×¢ÖØ£º
- ÓÐЩÏÂÁî¿ÉÄÜ·µ»Ø·Ç 0 Öµ£¬×ÝÈ»ËüÃÇÖ´ÐÐÀֳɡ£ÀýÈ磬grep ÏÂÁî·µ»Ø·Ç 0 ÖµÌåÏÖûÓÐÆ¥ÅäÏî¡£
- ¹ØÓÚ Bash ¶øÑÔ£¬$? ±äÁ¿Ö»ÉúÑÄ×î½üÒ»¸öÏÂÁîµÄÍ˳ö״ֵ̬¡£
- ¹ØÓÚÆäËû Shell ¶øÑÔ£¬$? ±äÁ¿¿ÉÄÜ°üÀ¨²î±ð¼ÄÒåµÄÐÅÏ¢¡£ÀýÈ磬ÔÚ Zsh ÖУ¬ËüÌåÏÖÏÂÁîÖ´ÐÐÀú³ÌÖн¨ÉèµÄ×î´óÎļþÐÎò·û¡£
ÒÔÉϾÍÊÇshellÔõôÅжÏÏÂÁîÊÇ·ñÖ´ÐÐÀֳɵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡
ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£