diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-03-09 20:34:46 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-03-09 20:34:46 +0000 |
commit | 74e056bfc8e2d6f006548c0134502697c056f97a (patch) | |
tree | 676e4afbfb2edbbbe734d80b05c19706c4fdb37b /shell/lash.c | |
parent | 3c7361f53aab0d4c6cb3c46218810bda52693fab (diff) | |
download | busybox-w32-74e056bfc8e2d6f006548c0134502697c056f97a.tar.gz busybox-w32-74e056bfc8e2d6f006548c0134502697c056f97a.tar.bz2 busybox-w32-74e056bfc8e2d6f006548c0134502697c056f97a.zip |
Fixed a couple more cases. $FOO/bar ${FOO} and such now work
without wordexp. Of course for stuff like ${1:-foo} you still
need wordexp for them to work.
-Erik
Diffstat (limited to 'shell/lash.c')
-rw-r--r-- | shell/lash.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/shell/lash.c b/shell/lash.c index 34dca0449..8f19e526a 100644 --- a/shell/lash.c +++ b/shell/lash.c | |||
@@ -1014,7 +1014,6 @@ static int expand_arguments(char *command) | |||
1014 | * wordexp can't do for us, namely $? and $! */ | 1014 | * wordexp can't do for us, namely $? and $! */ |
1015 | src = command; | 1015 | src = command; |
1016 | while((dst = strchr(src,'$')) != NULL){ | 1016 | while((dst = strchr(src,'$')) != NULL){ |
1017 | printf("dollar '%s'\n", dst); | ||
1018 | var = NULL; | 1017 | var = NULL; |
1019 | switch(*(dst+1)) { | 1018 | switch(*(dst+1)) { |
1020 | case '?': | 1019 | case '?': |
@@ -1057,14 +1056,25 @@ static int expand_arguments(char *command) | |||
1057 | } else { | 1056 | } else { |
1058 | /* Looks like an environment variable */ | 1057 | /* Looks like an environment variable */ |
1059 | char delim_hold; | 1058 | char delim_hold; |
1060 | src=strpbrk(dst+1, " \t~`!$^&*()=|\\{}[];\"'<>?."); | 1059 | int num_skip_chars=1; |
1060 | int dstlen = strlen(dst); | ||
1061 | /* Is this a ${foo} type variable? */ | ||
1062 | if (dstlen >=2 && *(dst+1) == '{') { | ||
1063 | src=strchr(dst+1, '}'); | ||
1064 | num_skip_chars=2; | ||
1065 | } else { | ||
1066 | src=strpbrk(dst+1, " \t~`!$^&*()=|\\[];\"'<>?./"); | ||
1067 | } | ||
1061 | if (src == NULL) { | 1068 | if (src == NULL) { |
1062 | src = dst+strlen(dst); | 1069 | src = dst+dstlen; |
1063 | } | 1070 | } |
1064 | delim_hold=*src; | 1071 | delim_hold=*src; |
1065 | *src='\0'; /* temporary */ | 1072 | *src='\0'; /* temporary */ |
1066 | var = getenv(dst + 1); | 1073 | var = getenv(dst + num_skip_chars); |
1067 | *src=delim_hold; | 1074 | *src=delim_hold; |
1075 | if (num_skip_chars==2) { | ||
1076 | src++; | ||
1077 | } | ||
1068 | } | 1078 | } |
1069 | if (var == NULL) { | 1079 | if (var == NULL) { |
1070 | /* Seems we got an un-expandable variable. So delete it. */ | 1080 | /* Seems we got an un-expandable variable. So delete it. */ |