From 2d91384197847a7e8fe2c3f548918a8277d3086d Mon Sep 17 00:00:00 2001 From: Miguel Date: Tue, 18 Sep 2018 03:03:28 +0200 Subject: sysfs, errno, improve foolshell, etc --- userspace/foolshell.c | 279 ++++++++++++++++++++++++-------------------------- 1 file changed, 131 insertions(+), 148 deletions(-) (limited to 'userspace/foolshell.c') diff --git a/userspace/foolshell.c b/userspace/foolshell.c index 0012592..e8b384e 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -1,47 +1,45 @@ +/** + * @file + * + * Fool's Shell + * ========= + * + * A minimalsitic and naive shell developed along the Fool OS kernel. + * TODO: Free tokenizer / dynamic size! + */ + #include #include #include #include - -#include +#include +#include extern char **environ; -extern struct _reent *_impure_ptr; -uint8_t buf_test[1024*300]; +bool process(char *buf); +bool cd(char *path); -// -void hello() +void version() +{ + puts("Fool's Shell version git-commit:" GIT_REVISION "\ncompiled on " __DATE__ " at " __TIME__); +} +void help() { - // ascci art: http://patorjk.com/software/taag/#p=testall&f=Cards&t=Fool%20OS - puts( - - "\033c" -// "\033[36m" - -// " ______ __ ____ _____ \n" -// " / ____/___ ____ / / / __ \\/ ___/ \n" -// " / /_ / __ \\/ __ \\/ / / / / /\\__ \\ \n" -// " / __/ / /_/ / /_/ / / / /_/ /___/ / \n" -// " /_/ \\____/\\____/_/ \\____//____/ \n" -// " \n" - -// "\033[37;44m" -// " \n" - - " Welcome to FoolShell v0.12 (Compiled on " __DATE__ " at " __TIME__")\n" - " ------------------------------------------------------------------\n\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" - " \n" - - "\033[37;40m" - ); - - 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")); + puts( "\nfoolshell: supported built-in commands/functions:\n\n" + + "'env' - show all environment variables\n" + "'getenv [var]' - show environment variable\n" + "'setenv [var] [val]' - set environemnet variable\n" + + "'cd [dir]' - change directory (set $PWD)\n" + "'[binary] [params...]' - run a binary\n" + "'[binary] [params...] &' - run a binary in background\n" + " TODO - pipes\n" + + "'help' - show this message\n" + "'exit' - exit running foolshell\n\n"); + } void prompt() @@ -49,23 +47,32 @@ void prompt() printf("\033[36mfool\033[37m@\033[32mhill\033[33m:%s%s\033[37m",getenv("PWD"),getenv("PS1")); } - int main(int argc, char **argv) { - bool silent=false; for(int i=0;i %s\n",p[pp]); + pp++; + } + t++; + } + + if(pp==0) + { + strcat(buf,"/"); + } + + for(int i=0;i