I have a script like this, named judge:
#!/bin/bash
echo "last exit status is $?"
It always outputs "last exit status is 0". Eg:
ls -l;   judge # correctly reports 0
ls -z;   judge # incorrectly reports 0
beedogs; judge # incorrectly reports 0
Why?


bashprocesses executing each line of code and$?isn't shared between the processes.