Reputation: 167
Im quite new to ksh scripting, please bear with me, if this is too obvious
What does this mean in ksh? Is this also a way to write an if condition?
[[ -n $MSRV_SGL ]] && {
msrv_ps || return 1
}
msrv_ps is a function
How does this read? if the length of string $MSRV_SGL is non zero....
?
I havent come across such expressions in any online examples.
Upvotes: 0
Views: 138
Reputation: 14955
Yes is telling you: if var length is not zero, execute function and return 1 if it's exit code is not zero.
It can be constructed as:
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.
Upvotes: 1