Article^ Parent
C 和 Bash Shell Script 中 if 语句的一些区别
Date: | 2013-05-02 11:10:04 |
Description: | C 中 if 语句的判断是以表达式的真假为依据的,值为 0 的表达式为假,值非 0 的表达式为真 |
Keywords: | C, Shell Script, 编程 |
Category: | engineering_technology/computer/code_interpreter/general |
Tag: | programming, shell |
Link: | https://www.diewuxi.com/blog/article/37.html |
C 中 if 语句的判断是以表达式的真假为依据的,值为 0 的表达式为假,值非 0 的表达式为真,表达式为真的值为1,表达式为假的值为 0。从根本上,if 只是判断表达式的值,若为非 0 则执行下面的语句。表达式都可以直接转换为值。
Bash Shell 中 if 语句的判断是以测试程序的返回值为依据的,测试成功返回值为 0,测试失败返回值为非 0。从根本上,if 只是判断程序运行是否成功,若成功则执行下面的语句。表达式不能转化为值,不能被 if 直接判断。
[
是 Bash Shell 的内置命令.
Comments [1]
-
WtQBfqjhOiRI[1#]axnSXrcMzGpUPQdT2024-08-22 19:20:30Reply