关于 ksh 中的 if 语句的说明
clarification regarding an if statement in ksh
我对 ksh 脚本很陌生,如果这太明显了,请多多包涵
这在 ksh 中是什么意思?这也是写if条件的方法吗?
[[ -n $MSRV_SGL ]] && {
msrv_ps || return 1
}
msrv_ps 是函数
这个怎么读? if the length of string $MSRV_SGL is non zero....
?
我在任何在线示例中都没有遇到过这样的表达式。
Yes 告诉你:如果 var length 不为零,则执行函数并且 return 1 如果它的退出代码不为零。
可以构造为:
if [[ -n $MSRV_SGL ]];then
if ! msrv_ps;then
return 1
fi
fi
{ list; }
list is simply executed in the current shell environment. list must be terminated with a newline or semicolon.
This is known as a group command.
The return status is the exit status of list. Note that unlike the metacharacters ( and ), { and } are reserved words and
must occur where a
reserved word is permitted to be recognized. Since they do not cause a word break, they must be separated from list by
whitespace or another
shell metacharacter.
我对 ksh 脚本很陌生,如果这太明显了,请多多包涵
这在 ksh 中是什么意思?这也是写if条件的方法吗?
[[ -n $MSRV_SGL ]] && {
msrv_ps || return 1
}
msrv_ps 是函数
这个怎么读? if the length of string $MSRV_SGL is non zero....
?
我在任何在线示例中都没有遇到过这样的表达式。
Yes 告诉你:如果 var length 不为零,则执行函数并且 return 1 如果它的退出代码不为零。
可以构造为:
if [[ -n $MSRV_SGL ]];then
if ! msrv_ps;then
return 1
fi
fi
{ list; } list is simply executed in the current shell environment. list must be terminated with a newline or semicolon. This is known as a group command. The return status is the exit status of list. Note that unlike the metacharacters ( and ), { and } are reserved words and must occur where a reserved word is permitted to be recognized. Since they do not cause a word break, they must be separated from list by whitespace or another shell metacharacter.