Enable the return command in scripts to leave a script before its actual end. (Can be used to notify the user that the current script is an install script: add return to the install section and print the notification afterwards)
In the Script class member function Script::getNextScriptCommand() one has to intercept the returned command and check, whether it equals return. In this case, one has to stop the script evaluation by calling Script::close() and setting bLastScriptCommand to true and returning an empty string.
If the script currently executed an install section, then one has to ensure that the install process is correctly terminated. This can be done by using the lines 736-744 at the correct location. The best solution would be to extract the whole logic into a private member function handling all this stuff.
The correct location to implement the return statement is in the Kernel in the function NumeReKernel::handleFlowControls(). The planned implementation from the previous analysis shall be added according to the following snippet:
if (_procedure.getLoop() || sCurrentCommand == "for" || sCurrentCommand == "if" || sCurrentCommand == "while" || sCurrentCommand == "switch")
{
...
if (!(_script.isValid() && _script.isOpen()) && !sCmdCache.length())
{
...
}
else
{
// check here for the existence of the return signal using
// FlowCtrl::getReturnSignal() and close the script, if needed
// set: nReturnVal = NUMERE_DONE_KEYWORD;
}
return false;
}
else if (sCurrentCommand == "return")
{
// close here the script
// set: nReturnVal = NUMERE_DONE_KEYWORD;
}
return true;
To ensure that the return signal is resetted correctly, add bReturnSignal = false to FlowCtrl::setCommand().
Script.return statements at the relevant locations (plain script, inside flow control block, inside an install section) were tested without deviation.This functionality was tested together with the install scripts provided by the package creator [#375]. No deviation occured.
Anonymous
Diff:
Diff:
Diff:
Diff:
Related
Commit: [r605]
Diff:
Related
Tickets:
#375