I have the following executable files:
set_status.sh
#!/bin/bash
exit $1
tst_set_status.sh
#!/bin/bash
1. echo arg1 = $1
2. ./set_status.sh $1
3. stat=$?
4. echo $?
5. if [ $stat -eq 0 ]; then
6. final_stat="ok"
7. fi
8. echo $stat
9. echo `echo $?`
So:
./tst_set_status.sh 1
arg1 = 1
0
1
0
Questions:
- Why does $stat have the value 0 and not 1 at line 4? Is line 4 printing the result of the shell asignment on line 3?
- Which command exit status is the ? variable reporting in line 9?