I'm trying to understand this bash code but I'm pretty new on this. I'm not sure how to interpreter the next snippet. In more specific way I have doubts with the if "@"; then
line.
check() {
LABEL=$1
shift
echo -e "\n Testing $LABEL"
if "$@"; then
echo "✅ Passed!"
return 0
else
echoStderr "❌ $LABEL check failed."
FAILED+=("$LABEL")
return 1
fi
}
I think that is just like the python list syntax to test an empty list the if
will be success when the command tested return something. But I have doubts because bash use a lot error signals and I may be missing something. The use case is:
check "distro" lsb_release -c
check "color" [ $(cat /tmp/color.txt | grep red) ]
The snippeds were taken from this repository
related question: What does mean $@ in bash script