I have a parent script, that execute a child script in background:
#!/bin/bash
# parent.sh
childScript $param1 $param2&
Child script:
#!/bin/bash
# childScript.sh
param1=$1
param2=$2
someLinuxCommand $param1 $param2
out=$?
echo $out
If I execute childScript.sh with correct $param1 and $param2, $? will return 0. If $param1 and $param2 are incorrect, $? will return 1.
But no matter what $param1 and $param2 I send using parent.sh, $? always return 0. Why if I send incorrect $param1 and $param2 from parent.sh, $? in childScript.sh return 0?
someLinuxCommandis correct and then removeout=$?andecho $out.