1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:38:12 +00:00

Shell: Implement the return POSIX builtin

This is also available in the regular shell mode, as it's a generally
useful builtin to have.
This commit is contained in:
Ali Mohammad Pur 2023-10-16 21:21:22 +03:30 committed by Andrew Kaster
parent 2d1c5dbfcb
commit a8c7448ccb
4 changed files with 25 additions and 1 deletions

View file

@ -487,6 +487,9 @@ bool Shell::invoke_function(const AST::Command& command, int& retval)
(void)function.body->run(*this);
if (has_error(ShellError::InternalControlFlowReturn))
take_error();
retval = last_return_code.value_or(0);
return true;
}
@ -2435,6 +2438,7 @@ void Shell::possibly_print_error() const
break;
case ShellError::InternalControlFlowBreak:
case ShellError::InternalControlFlowContinue:
case ShellError::InternalControlFlowReturn:
case ShellError::InternalControlFlowInterrupted:
case ShellError::InternalControlFlowKilled:
return;