diff options
| author | Michal Idziorek <m.i@gmx.at> | 2014-12-05 01:46:25 +0100 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2014-12-05 01:46:25 +0100 |
| commit | 73c5852c068f3dcd58cdb8617251c5aca59b2460 (patch) | |
| tree | cb94216f274c84749355518b4ced8a1c29e0e9cd /userspace | |
| parent | 2acfe7e10cff427998049d58df11830b4bbe1c9e (diff) | |
minor fixes in foolshell
Diffstat (limited to 'userspace')
| -rw-r--r-- | userspace/foolshell.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/userspace/foolshell.c b/userspace/foolshell.c index 7d2291e..d44204c 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -16,15 +16,16 @@ void hello() " / __/ / /_/ / /_/ / / / /_/ /___/ / \n" " /_/ \\____/\\____/_/ \\____//____/ \n" " \n" - "Welcome to FoolShell v0.5 (Compiled on " __DATE__ " at " __TIME__ "\n" + "Welcome to FoolShell v0.6 (Compiled on " __DATE__ " at " __TIME__ "\n" "------------------------------------------------------------------\n\n" - "Please type 'help' anytime, to show shell \"built-ins\" or execute \n" - "user programms that are in you $PATH directory by simply typing \n" - "their filenames. You can get additional information for many commands\n" - "by invoking them with the --help or -h flag (e.g. ls --help) \n" + "Please type 'help' anytime, to show shell \"built-ins\". You can execute \n" + "user programms that are in your $PATH directory by simply typing \n" + "their filenames. Get additional information for many, of the available\n" + "commands by invoking them with --help or -h. (e.g. ls --help) \n" ); - printf("Your $PATH is currently set to: %s\n\n",getenv("PATH")); + printf("Your $PATH is currently set to: %s\n",getenv("PATH")); + printf("Type 'ls %s' to list programms on your $PATH.\n\n",getenv("PATH")); } void prompt() @@ -109,7 +110,14 @@ 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]', 'exit'"); + puts( "\nfoolshell: supported built-in commands:\n\n" + "'help' - show this message\n" + "'echo [string]' - print given string to stdout\n" + "'getenv [var]' - show environment variable\n" + "'putenv/setenv [var] [val]' - set environemnet variable\n" + "'env' - show all environment variables\n" + "'cd [dir]' - change directory (set $PWD)\n" + "'exit' - exit running foolshell\n\n"); } else if(!strcmp(command,"cd")) { @@ -163,14 +171,13 @@ int process(char *buf) int i=0; if(left!=1)buf[left++]='/'; do{buf[left++]=token[i++];}while(token[i]!=0); - } }while(buf[right]!=0); buf[left]=0; // printf("adjusted: '%s'\n",buf); - - setenv("PWD",buf,1); + if(buf[0]==0)setenv("PWD","/",1); + else setenv("PWD",buf,1); } else if(!strcmp(command,"exit")) @@ -183,16 +190,6 @@ int process(char *buf) printf("\"%s\"\n",token[1]); } - else if(!strcmp(command,"malloc")) - { - uint8_t *mall=malloc(atoi(token[1])); - printf("allocated %d bytes at 0x%08X (%i).\n",atoi(token[1]),mall,mall); - } - else if(!strcmp(command,"free")) - { - free(atoi(token[1])); - printf("called free(0x%08X).\n",atoi(token[1])); - } else if(!strcmp(command,"getenv")) { printf("(0x%08X) get: '%s' = '%s'(0x%08X) \n",environ,token[1],getenv(token[1]),getenv(token[1])); @@ -219,13 +216,14 @@ int process(char *buf) int pid=fork(); if(pid!=0) { - printf("new task pid: %i \n",pid); + //printf("new task pid: %i \n",pid); } if(pid==0) { char buf[256]; + sprintf(buf,"%s",token[0]); + execve(buf,token,environ); 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); |
