diff --git a/README.md b/README.md index b1f243f..d7000f8 100644 --- a/README.md +++ b/README.md @@ -5,19 +5,25 @@ Going to try and make it mostly POSIX compliant. ## todo +- [ ] rewrite handle arg function. tis bad pointer stuff - [x] environment variables - [x] custom prompts +- [ ] fix prompt to use PS1 environment variable - [x] minimal current directory - [ ] handle ~ - [ ] dynamically allocate cwd in cd builtin command +- [ ] history +- [ ] cursor movement +- [ ] tab to autocomplete files and dirs - [ ] all of posixsxssssss - [ ] aliases - [x] increase the SHLVL var - [x] update pwd - [ ] quotes - [ ] pipes | + - [ ] vi mode - [ ] redirections > < - [ ] append >> - [ ] heredoc - [ ] rcfile - - [ ] rcfile in homedir + - [ ] rcfile in config dir diff --git a/src/lsh_main_func.c b/src/lsh_main_func.c index c144238..fdaa011 100644 --- a/src/lsh_main_func.c +++ b/src/lsh_main_func.c @@ -45,12 +45,32 @@ char *lsh_read_line(void) } } +//this needs to be rewritten/moved for better memory management. eg not writing to getenv or a pointer to a string that must not be modified +//eg dont use token=some pointer char *handle_vars(char *token){ token=&token[0]; if (token[0] == '$'){ token=&token[1]; - token=getenv(token); + if(getenv(token)){ + token=getenv(token); + } else { + token=""; + } } + /* + if (token[0] == '~'){ + token=&token[1]; + char *orig = (char*)malloc(sizeof(char) * ( strlen(token) + strlen(getenv("HOME") + 1))); + strcpy(orig,token); + + strcpy(token,getenv("home")) has a weird doubling memory thing i dont understand + strcpy(token,getenv("HOME")); + + strcat(token,orig); + printf("TOK: %s\n\n",token); + free(orig); + } + */ return token; }