What does this mean?
if ${ac_cv_lib_lept_pixCreate+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
Looks like ac_cv_lib_lept_pixCreate
is some variable, so what does +:
mean?
Where to learn complete syntax of curly bracket expressions? What is the name of this syntax?
Description. The : (colon) command is used when a command is needed, as in the then condition of an if command, but nothing is to be done by the command. This command simply yields an exit status of zero (success). This can be useful, for example, when you are evaluating shell expressions for their side effects.
$() – the command substitution. ${} – the parameter substitution/variable expansion.
$# is the number of positional parameters passed to the script, shell, or shell function. This is because, while a shell function is running, the positional parameters are temporarily replaced with the arguments to the function. This lets functions accept and use their own positional parameters.
It's nothing, these colons are part of the command names apparently. You can verify yourself by creating and running a command with : in the name. The shell by default will autoescape them and its all perfectly legal. Follow this answer to receive notifications.
In the “plus colon” ${...+:}
expression, only the +
has special meaning in the shell. The colon is just a string value in this case, so we could write that snippet as ${...+":"}
.
For convenience, let's pretend the variable is called var
, and consider the expression:
if ${var+:} false; then ...
If the shell variable $var
exists, the entire expression is replaced with :
, if not, it returns an empty string.
Therefore the entire expression ${var+:} false
becomes either : false
(returning true) or false
(returning false).
This comes down to a test for existence, which can be true even if the variable has no value assigned.
It is very cryptic, but as it happens, is one of the few tests for the existence of a variable that actually works in most, if not all, shells of Bourne descent.
Possible equivalents: (substitute any variable name here for var
)
if [[ ${var+"is_set"} == is_set ]]; then ...
Or, probably more portable:
case ${var+"IS_SET"} in IS_SET) ...;; esac
Shell Parameter Expansion documentation for bash is here. No mention of +:
, though it does mention :+
:
${parameter:+word}
If parameter is null or unset, nothing is substituted, otherwise the expansion of word is substituted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With