Skip to main content
deleted 194 characters in body
Source Link

🔴 The rest of answers are highly slow, because of comparing values.

Justway with the storehighest performance in theis by checking if a variable the right boolean commandis empty or not:

#true:
condition="true"

#false:
condition="false"

Then run it as a command. For example:

# echo resultcondition=""
if "${condition}"; then
    echo "yes"
else#true:
    echo "no"condition=x
fi
#check:
#[[ exit-n status
"${condition}" ]]

🔴 The rest of answers are highly slow, because of comparing values.

Just store in the variable the right boolean command:

#true:
condition="true"

#false:
condition="false"

Then run it as a command. For example:

# echo result
if "${condition}"; then
    echo "yes"
else
    echo "no"
fi

# exit status
"${condition}" 

The way with the highest performance is by checking if a variable is empty or not:

#false:
condition=""

#true:
condition=x

#check:
[[ -n "${condition}" ]]
added 167 characters in body
Source Link

🔴 The rest of answersrest of answers are highly slow, because of comparing values.

Do not check if a booleanJust store in the variable equals to anything, but if it's empty or not.the right boolean command:

#false#true:
condition=""condition="true"

#true#false:
condition=xcondition="false"

Then run it as a command. For example:

# echo result
#check:if "${condition}"; then
[ -n   echo "yes"
else
    echo "no"
fi

# exit status
"${condition}" ]

🔴 The rest of answers are highly slow.

Do not check if a boolean variable equals to anything, but if it's empty or not.

#false:
condition=""

#true:
condition=x

#check:
[ -n "${condition}" ]

🔴 The rest of answers are highly slow, because of comparing values.

Just store in the variable the right boolean command:

#true:
condition="true"

#false:
condition="false"

Then run it as a command. For example:

# echo result
if "${condition}"; then
    echo "yes"
else
    echo "no"
fi

# exit status
"${condition}" 
added 26 characters in body
Source Link

🔴 The rest of answers are highly slow.

Do not check if a boolean variable equals to anything, but if it's empty or not. It's way faster.

#false:
condition=""

#true:
condition=x

#check:
[ -n "${condition}" ]

Do not check if a boolean variable equals to anything, but if it's empty or not. It's way faster.

#false:
condition=""

#true:
condition=x

#check:
[ -n "${condition}" ]

🔴 The rest of answers are highly slow.

Do not check if a boolean variable equals to anything, but if it's empty or not.

#false:
condition=""

#true:
condition=x

#check:
[ -n "${condition}" ]
Source Link
Loading