Suppose that there is a batch file (caller) that executes another batch file (called), the call command should be used to return to the caller after the call is completed. Here is an example:
caller.bat :
echo Calling another script... call callee.bat echo Returned from callee...
callee.bat (in the same place) :
echo Being called from caller...
The output will be like this (excluding echo commands), showing that the execution returned as expected:
Calling another script... Being called from caller... Returned from callee...
If the call command was fired at the caller, the output will be:
Calling another script... Being called from caller...
But once the called object is involved in the pipe ( | ), there is no difference if the call command is used. For instance:
caller.bat (called remains unchanged) :
echo Calling another script... break | callee.bat echo Returned from callee...
The output will be this, although there is no call command.
Calling another script... Being called from caller... Returned from callee...
What is the reason for this behavior that causes execution to return to the caller here?
source share