I´m using to wait until a service is up and runnig, but using curl after the first attemp to connect and fail the whole script exit. How can avoid the exit after the fail of the curl?. I´ve tried using --fail on curl but nothing.
Here my code
#!/bin/bash
getX(){
echo `curl --fail domain.com` --> should return an array
}
test(){
result=`getX`
while [ ${#result[@]} -eq 0 ]
do
echo "waiting"
result=`getX`
done
}
test
set -e, the script will exit immediately if a pipeline returns a non-zero status. gnu.org/software/bash/manual/html_node/The-Set-Builtin.html--faildoesn't prevent a non-zero status, it just prevents output on HTTP errors.curldoes not return an array. It may be returning a JSON list, but that is not the same as abasharray.$result, not array operations 4) if you're trying to replay a curl call that returned an HTTP error, you should test curl's return code rather than returned content