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

Shell: Add support for unset -v in POSIX mode

This commit is contained in:
Ali Mohammad Pur 2023-04-19 12:17:38 +03:30 committed by Ali Mohammad Pur
parent 71441ea932
commit e2336d9de5

View file

@ -1198,9 +1198,12 @@ ErrorOr<int> Shell::builtin_wait(Main::Arguments arguments)
ErrorOr<int> Shell::builtin_unset(Main::Arguments arguments)
{
Vector<DeprecatedString> vars;
bool unset_only_variables = false; // POSIX only.
Core::ArgsParser parser;
parser.add_positional_argument(vars, "List of variables", "variables", Core::ArgsParser::Required::Yes);
if (m_in_posix_mode)
parser.add_option(unset_only_variables, "Unset only variables", "variables", 'v');
if (!parser.parse(arguments, Core::ArgsParser::FailureBehavior::PrintUsage))
return 1;
@ -1212,7 +1215,7 @@ ErrorOr<int> Shell::builtin_unset(Main::Arguments arguments)
if (TRY(lookup_local_variable(value)) != nullptr) {
unset_local_variable(value);
} else {
} else if (!unset_only_variables) {
unsetenv(value.characters());
}
}