1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:37:36 +00:00

Shell: Add builtin command to reset the internal state

The new builtin command "reset" now resets the entire internal state by
virtually destructing the Shell state and re-constructing it.

This helps for example when setting a new hostname and wanting to view
it in the current Shell program.
This commit is contained in:
Liav A 2023-08-11 13:11:15 +03:00 committed by Ali Mohammad Pur
parent 489fce0ed2
commit fb60db7b00
3 changed files with 27 additions and 3 deletions

View file

@ -149,6 +149,17 @@ ErrorOr<int> Shell::builtin_where(Main::Arguments arguments)
return at_least_one_succeded ? 0 : 1;
}
ErrorOr<int> Shell::builtin_reset(Main::Arguments)
{
destroy();
initialize(m_is_interactive);
// NOTE: As the last step before returning, clear (flush) the shell text entirely.
fprintf(stderr, "\033[3J\033[H\033[2J");
fflush(stderr);
return 0;
}
ErrorOr<int> Shell::builtin_alias(Main::Arguments arguments)
{
Vector<DeprecatedString> aliases;