I have a
val.py python script that returns a negative number.
import sys sys.exit(-1234)
When I run this bash script, I get the value
$? as return value of 46 (not -1234).
Even when I tried to compare the value with
$? == 46 or
$? == "46", it doesn't work at all.
python val.py echo $? if [ $? == 46 ]; then echo "Match" else echo "NO" fi
- Q1 : Why the return value is not correctly stored in
- Q2 : Why the $? == NUMBER comparison doesn't work?