dimanche 4 décembre 2016

Fail if condition function is undefined

Suppose I use a function in an if statement:

if isSomeConditionTrue; then
  echo "true";
else
  echo "false";
fi

This works fine if isSomeConditionTrue is defined.

However, if isSomeConditionTrue is not defined, e.g. due to a typo or a missing import, it evaluates to "false" rather than failing.

set -u doesn't make a difference.

Aucun commentaire:

Enregistrer un commentaire