diff options
Diffstat (limited to 'userspace/shell.c')
| -rw-r--r-- | userspace/shell.c | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/userspace/shell.c b/userspace/shell.c index 06a03d2..83f1e6f 100644 --- a/userspace/shell.c +++ b/userspace/shell.c @@ -2,15 +2,16 @@ #include <stdint.h> #include <string.h> -#include "../fs/fs.h" -void hello() { +void hello() +{ puts( "Welcome to FoolShell v0.1" ); } -void prompt() { +void prompt() +{ printf( "$ " ); @@ -87,20 +88,7 @@ int process(char *buf) if(!strcmp(command,"help")) { - puts("foolshell: supported built-in commands: 'help', 'echo [string]', 'ls [inode_nr]', exec [inode_nr],'malloc [bytes]', 'free [address]', 'getenv [var]', 'putenv [var] [val]'"); - } - else if(!strcmp(command,"ls")) - { - fs_dirent *dirs=malloc(sizeof(fs_dirent)*25); - - int ls=readdir(atoi(token[1]),dirs,25); - - int i; - for(i=0;i<ls;i++) - { - printf("foolshell: %i %s%c\n",dirs[i].inode, dirs[i].name, ((dirs[i].type==FS_FILE_TYPE_DIR)?'/':' ')); - } - + puts("foolshell: supported built-in commands: 'help', 'echo [string]', exec [inode_nr],'malloc [bytes]', 'free [address]', 'getenv [var]', 'putenv [var] [val]'"); } else if(!strcmp(command,"exec")) { @@ -109,37 +97,35 @@ int process(char *buf) } else if(!strcmp(command,"echo")) { - printf("foolshell: \"%s\"\n",token[1]); + printf("\"%s\"\n",token[1]); } else if(!strcmp(command,"malloc")) { uint8_t *mall=malloc(atoi(token[1])); - printf("foolshell: allocated %d bytes at 0x%08X (%i).\n",atoi(token[1]),mall,mall); + printf("allocated %d bytes at 0x%08X (%i).\n",atoi(token[1]),mall,mall); } else if(!strcmp(command,"free")) { free(atoi(token[1])); - printf("foolshell: called free(0x%08X).\n",atoi(token[1])); + printf("called free(0x%08X).\n",atoi(token[1])); } else if(!strcmp(command,"getenv")) { - printf("foolshell: %s = %s \n",token[1],getenv(token[1])); + printf("%s = %s \n",token[1],getenv(token[1])); } else if(!strcmp(command,"putenv")) { char buf[256]; sprintf(buf,"%s=%s",token[1],token[2]); putenv(buf); - printf("foolshell: %s = %s \n",token[1],getenv(token[1])); + printf("set: %s = %s \n",token[1],getenv(token[1])); } else { puts("foolshell: command not found"); } - - // } |
