I have next code:
...
docker_test () {
local masterip=$1
nc -zv $masterip 2377
}
...
until $(docker_test $masterip); do
echo "First Master not initialized yet..."
sleep 30
done
...
The question is - is it correct approach in bash to use loops or if/else in a such way?
Another example could be:
if $(docker_test $masterip); then
echo "Passed"
fi
nc -zv..until it is successful (returning a code0) this looks fineuntil $(funcname); thenconstruction. Will beuntil [ "$(docker_test $masterip)" == "0" ]more correct way here? Or it can be safly simplified to the same code, as mine is?until docker_test "$master_ip"; do. Otherwise,until [ "$(docker_test "$master_ip")" = 0 ](=, not==) is correct.