Be Careful when sourcing a script
Table of Contents
1 Bug Description
The story comes from my assistant for my colleague to debug an issue.
Process A Logic as below:
while Process A does not get result Y from script ddcc.sh sh ddcc.sh
and the script logic for ddcc.sh as below:
. /lib/ipp88x.sh local h=$(ipp88x_name) result=Y
The phenomenon is, Process A invoke ddcc.sh again and again, and
never stop.
2 Reason
There is no file /lib/ipp88x.sh exist!
and when run the script ddcc.sh, the code below:
. /lib/ipp88x.sh
will stop the script ddcc.sh and return error immediately!
with error below:
ddcc.sh: .: line 3: can't open '/lib/ipp88x.sh'
and the code below will never reached
result=Y
3 Background Knowledge
. MyScript
The execute command (a single period) followed by the name of the
script.
The difference between that and using the sh command is that
the sh command starts a new process and the execute command does
not.