diff options
| author | iceyrazor <iceyrazor@mailfence.com> | 2026-02-27 20:36:45 -0600 |
|---|---|---|
| committer | iceyrazor <iceyrazor@mailfence.com> | 2026-02-27 20:36:45 -0600 |
| commit | becbecb016f16c2dea64aacd7077973f45ed0517 (patch) | |
| tree | e498700c16d5c69373f5caafd95070cecbcfedad /src/lsh_main_func.c | |
| parent | b6a561f81c569ccc63423dc69eca4bc082ea60e9 (diff) | |
made vars delimited by $ as well. eg $HOME$HOME now works
Diffstat (limited to 'src/lsh_main_func.c')
| -rw-r--r-- | src/lsh_main_func.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lsh_main_func.c b/src/lsh_main_func.c index aa16cbd..5f46183 100644 --- a/src/lsh_main_func.c +++ b/src/lsh_main_func.c @@ -67,7 +67,15 @@ char *handle_vars(char *token){ int i=0; while (tmp_token[i]!='\0'){ if(tmp_token[i]=='$'){ - int j=0; while(tmp_token[i+j]!=' ' && tmp_token[i+j]) j++; + char sep[2]=" \0"; + int j=0; while(tmp_token[i+j]){ + j++; + if(tmp_token[i+j]==' ') break; + if(tmp_token[i+j]=='$'){ + sep[0]='$'; + break; + } + } char *varname=(char*)malloce(sizeof(char)*j+1); varname[j]='\0'; @@ -75,9 +83,7 @@ char *handle_vars(char *token){ varname[j-1]='\0'; char *env = getenv(varname); - if(!env){ - env=""; - } + if(!env) env=""; free(ret_token); int tmp_len=strlen(tmp_token); @@ -87,7 +93,7 @@ char *handle_vars(char *token){ strcpy(ret_token,tmp_token); strcat(ret_token,env); - strcat(ret_token," "); + strcat(ret_token,sep); if(i+j+1 < tmp_len){ strcat(ret_token,&tmp_token[i+j+1]); } |
