Home > database >  Significance of [[ "$var" ]] in bash
Significance of [[ "$var" ]] in bash

Time:11-23

I have difficulty figuring out what this does

if [[ "$invoke" ]]; then

Have looked at the bash manual which is 190 pages long and could not identify the relavant part that might help me understand.

CodePudding user response:

bash(1) says:

[[ expression ]]

Return a status of 0 or 1 depending on the evaluation of the conditional expression expression. Expressions are composed of the primaries described below under CONDITIONAL EXPRESSIONS. Word splitting and pathname expansion are not performed on the words between the [[ and ]]; tilde expansion, parameter and variable expansion, arithmetic expansion, command substitution, process substitution, and quote removal are performed. Conditional operators such as -f must be unquoted to be recognized as primaries.

and later in the CONDITIONAL EXPRESSIONS section:

string
-n string

True if the length of string is non-zero.

  • Related