mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:38:11 +00:00
LibC/Shell: Add unsetenv(), and unset builtin calling it in Shell.
This commit is contained in:
parent
b2dd12daac
commit
abb7455163
3 changed files with 45 additions and 2 deletions
|
@ -80,6 +80,17 @@ static int sh_export(int argc, char** argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int sh_unset(int argc, char** argv)
|
||||
{
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "usage: unset variable\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsetenv(argv[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sh_cd(int argc, char** argv)
|
||||
{
|
||||
char pathbuf[PATH_MAX];
|
||||
|
@ -167,6 +178,10 @@ static bool handle_builtin(int argc, char** argv, int& retval)
|
|||
retval = sh_export(argc, argv);
|
||||
return true;
|
||||
}
|
||||
if (!strcmp(argv[0], "unset")) {
|
||||
retval = sh_unset(argc, argv);
|
||||
return true;
|
||||
}
|
||||
if (!strcmp(argv[0], "history")) {
|
||||
retval = sh_history(argc, argv);
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue