mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:18:13 +00:00
Shell: Implement a very basic exec builtin
Other shells also support a number of other options with exec and some have special behaviour when calling exec with no arguments except redirections. This PR only supports the basic case of replacing the Shell process (or LibShell host process) with the provided command.
This commit is contained in:
parent
50d24e4f98
commit
96cd04f2ba
3 changed files with 59 additions and 36 deletions
|
@ -256,6 +256,20 @@ int Shell::builtin_dirs(int argc, const char** argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Shell::builtin_exec(int argc, const char** argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Shell: No command given to exec\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Vector<const char*> argv_vector;
|
||||
argv_vector.append(argv + 1, argc - 1);
|
||||
argv_vector.append(nullptr);
|
||||
|
||||
execute_process(move(argv_vector));
|
||||
}
|
||||
|
||||
int Shell::builtin_exit(int argc, const char** argv)
|
||||
{
|
||||
int exit_code = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue