summaryrefslogtreecommitdiff
path: root/userspace/foolshell.c
diff options
context:
space:
mode:
Diffstat (limited to 'userspace/foolshell.c')
-rw-r--r--userspace/foolshell.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/userspace/foolshell.c b/userspace/foolshell.c
index 78ba327..7d2291e 100644
--- a/userspace/foolshell.c
+++ b/userspace/foolshell.c
@@ -109,7 +109,7 @@ int process(char *buf)
if(!strcmp(command,"help"))
{
- puts("foolshell: supported built-in commands: 'help', 'echo [string]', 'malloc [bytes]', 'free [address]', 'getenv [var]', 'putenv/setenv [var] [val]', 'env' 'cd [dir]'");
+ puts("foolshell: supported built-in commands: 'help', 'echo [string]', 'malloc [bytes]', 'free [address]', 'getenv [var]', 'putenv/setenv [var] [val]', 'env' 'cd [dir]', 'exit'");
}
else if(!strcmp(command,"cd"))
{
@@ -173,6 +173,11 @@ int process(char *buf)
setenv("PWD",buf,1);
}
+ else if(!strcmp(command,"exit"))
+ {
+ exit(1);
+
+ }
else if(!strcmp(command,"echo"))
{
printf("\"%s\"\n",token[1]);
@@ -215,12 +220,18 @@ int process(char *buf)
if(pid!=0)
{
printf("new task pid: %i \n",pid);
+ }
+ if(pid==0)
+ {
char buf[256];
sprintf(buf,"%s/%s",getenv("PATH"),token[0]);
+ sprintf(buf,"%s/%s","/bin",token[0]);
execve(buf,token,environ);
puts("foolshell: command not found");
exit(1);
}
+ int status;
+ wait(&status);
}
return 0;