下面两个KornShell (ksh)代码段之间有什么区别,因为它们在测试期间的行为都是完全相同的。返回代码(例如,退出代码、返回状态、退出状态、returnCode)来自SQL*Plus命令(如果有关系的话)。
kornShellSnippet1.ksh
returnCode=${?}
if [[ ${returnCode} -ne 0 ]]; then #successful command returns 0#kornShellSnippet2.ksh
returnCode=${?}
if [[ ${returnCode} != 0 ]]; then #successful command returns 0#发布于 2014-01-07 18:28:51
-ne是一个数值测试,!=是一个字符串测试。因为您知道$?是一个数字,所以使用数字测试是有意义的。
发布于 2016-08-05 11:58:52
据我所知,-ne是支持向后兼容性的遗留语法,而(至少在ksh双方括号内) !=等是本机ksh语法。
但是,为了比较数字,你不会使用算术语法吗?
let returnCode=${?}
if (( returnCode != 0 )); then #successful command returns 0#https://stackoverflow.com/questions/20978669
复制相似问题