I have a bash script which have some helper function inside a shared, common file lib.sh
. However, some of these functions look like this:
function check_prs {
local labels
labels=$(hub pr show -h "${BRANCH:-}" -F '%L')
if [[ $PRLABELS == *"DOTHING"* ]]
then true
else false
fi
}
The problem is that the command substitution and labels
variable assignment is done when the script is loaded (source lib.sh
from my main script), regardless of whether the function is called (or when).
Is there a way to only make these command substitutions when the function is actually called? Or some other way to make it behave as everything else in the normal flow of the script?