From becbecb016f16c2dea64aacd7077973f45ed0517 Mon Sep 17 00:00:00 2001 From: iceyrazor Date: Fri, 27 Feb 2026 20:36:45 -0600 Subject: made vars delimited by $ as well. eg $HOME$HOME now works --- src/lsh_main_func.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') 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]); } -- cgit v1.3