My bash script runs curl command internally. I want to return the HTTP response code as the status of my script.
I'm doing this like here:
statusCode=404
if [ $statusCode -ne 200 ]
then
echo $statusCode
exit $statusCode
fi
exit 0
Status code is echoed properly (404), but status value ($?) is 148. What am I doing wrong?
This is not possible to exit with HTTP response code from bash script,
because bash script can only exit with values 0-255.
Value 404 overflowed and turned into 148:
404 mod 256=148
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With