- added handling for ~
- fixed crash when $VAR is null
This commit is contained in:
@@ -7,17 +7,22 @@ Going to try and make it mostly POSIX compliant.
|
||||
|
||||
- [x] environment variables
|
||||
- [x] custom prompts
|
||||
- [ ] fix prompt to use PS1 environment variable
|
||||
- [x] minimal current directory
|
||||
- [ ] handle ~
|
||||
- [x] 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
|
||||
|
||||
@@ -49,7 +49,24 @@ 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);
|
||||
|
||||
//do not use strcpy(token,getenv("home"))
|
||||
//it does weird doubleing memeory thing i dont understand
|
||||
token=getenv("HOME");
|
||||
|
||||
strcat(token,orig);
|
||||
printf("TOK: %s\n\n",token);
|
||||
free(orig);
|
||||
}
|
||||
|
||||
return token;
|
||||
|
||||
Reference in New Issue
Block a user