aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-03-10 07:12:12 +0000
committerEric Andersen <andersen@codepoet.org>2001-03-10 07:12:12 +0000
commit1365bb786155439041b7777d31bcfadb5276e824 (patch)
tree8920760c17eff02678dc81ae6e29d6e108f1d86c
parent78f57460f2776aeddb584dd10923959f26863ea5 (diff)
downloadbusybox-w32-1365bb786155439041b7777d31bcfadb5276e824.tar.gz
busybox-w32-1365bb786155439041b7777d31bcfadb5276e824.tar.bz2
busybox-w32-1365bb786155439041b7777d31bcfadb5276e824.zip
When using wordexp, only try to use the expand command
when something actually got expanded. Skip it otherwise. -Erik
-rw-r--r--lash.c26
-rw-r--r--sh.c26
-rw-r--r--shell/lash.c26
3 files changed, 42 insertions, 36 deletions
diff --git a/lash.c b/lash.c
index 8f19e526a..d321c929b 100644
--- a/lash.c
+++ b/lash.c
@@ -941,20 +941,22 @@ static int expand_arguments(char *command)
941 return FALSE; 941 return FALSE;
942 } 942 }
943 943
944 /* Convert from char** (one word per string) to a simple char*, 944 if (expand_result.we_wordc > 0) {
945 * but don't overflow command which is BUFSIZ in length */ 945 /* Convert from char** (one word per string) to a simple char*,
946 *command = '\0'; 946 * but don't overflow command which is BUFSIZ in length */
947 while (i < expand_result.we_wordc && total_length < BUFSIZ) { 947 *command = '\0';
948 length=strlen(expand_result.we_wordv[i])+1; 948 while (i < expand_result.we_wordc && total_length < BUFSIZ) {
949 if (BUFSIZ-total_length-length <= 0) { 949 length=strlen(expand_result.we_wordv[i])+1;
950 error_msg(out_of_space); 950 if (BUFSIZ-total_length-length <= 0) {
951 return FALSE; 951 error_msg(out_of_space);
952 return FALSE;
953 }
954 strcat(command+total_length, expand_result.we_wordv[i++]);
955 strcat(command+total_length, " ");
956 total_length+=length;
952 } 957 }
953 strcat(command+total_length, expand_result.we_wordv[i++]); 958 wordfree (&expand_result);
954 strcat(command+total_length, " ");
955 total_length+=length;
956 } 959 }
957 wordfree (&expand_result);
958#else 960#else
959 961
960 /* Ok. They don't have a recent glibc and they don't have uClibc. Chances 962 /* Ok. They don't have a recent glibc and they don't have uClibc. Chances
diff --git a/sh.c b/sh.c
index 8f19e526a..d321c929b 100644
--- a/sh.c
+++ b/sh.c
@@ -941,20 +941,22 @@ static int expand_arguments(char *command)
941 return FALSE; 941 return FALSE;
942 } 942 }
943 943
944 /* Convert from char** (one word per string) to a simple char*, 944 if (expand_result.we_wordc > 0) {
945 * but don't overflow command which is BUFSIZ in length */ 945 /* Convert from char** (one word per string) to a simple char*,
946 *command = '\0'; 946 * but don't overflow command which is BUFSIZ in length */
947 while (i < expand_result.we_wordc && total_length < BUFSIZ) { 947 *command = '\0';
948 length=strlen(expand_result.we_wordv[i])+1; 948 while (i < expand_result.we_wordc && total_length < BUFSIZ) {
949 if (BUFSIZ-total_length-length <= 0) { 949 length=strlen(expand_result.we_wordv[i])+1;
950 error_msg(out_of_space); 950 if (BUFSIZ-total_length-length <= 0) {
951 return FALSE; 951 error_msg(out_of_space);
952 return FALSE;
953 }
954 strcat(command+total_length, expand_result.we_wordv[i++]);
955 strcat(command+total_length, " ");
956 total_length+=length;
952 } 957 }
953 strcat(command+total_length, expand_result.we_wordv[i++]); 958 wordfree (&expand_result);
954 strcat(command+total_length, " ");
955 total_length+=length;
956 } 959 }
957 wordfree (&expand_result);
958#else 960#else
959 961
960 /* Ok. They don't have a recent glibc and they don't have uClibc. Chances 962 /* Ok. They don't have a recent glibc and they don't have uClibc. Chances
diff --git a/shell/lash.c b/shell/lash.c
index 8f19e526a..d321c929b 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -941,20 +941,22 @@ static int expand_arguments(char *command)
941 return FALSE; 941 return FALSE;
942 } 942 }
943 943
944 /* Convert from char** (one word per string) to a simple char*, 944 if (expand_result.we_wordc > 0) {
945 * but don't overflow command which is BUFSIZ in length */ 945 /* Convert from char** (one word per string) to a simple char*,
946 *command = '\0'; 946 * but don't overflow command which is BUFSIZ in length */
947 while (i < expand_result.we_wordc && total_length < BUFSIZ) { 947 *command = '\0';
948 length=strlen(expand_result.we_wordv[i])+1; 948 while (i < expand_result.we_wordc && total_length < BUFSIZ) {
949 if (BUFSIZ-total_length-length <= 0) { 949 length=strlen(expand_result.we_wordv[i])+1;
950 error_msg(out_of_space); 950 if (BUFSIZ-total_length-length <= 0) {
951 return FALSE; 951 error_msg(out_of_space);
952 return FALSE;
953 }
954 strcat(command+total_length, expand_result.we_wordv[i++]);
955 strcat(command+total_length, " ");
956 total_length+=length;
952 } 957 }
953 strcat(command+total_length, expand_result.we_wordv[i++]); 958 wordfree (&expand_result);
954 strcat(command+total_length, " ");
955 total_length+=length;
956 } 959 }
957 wordfree (&expand_result);
958#else 960#else
959 961
960 /* Ok. They don't have a recent glibc and they don't have uClibc. Chances 962 /* Ok. They don't have a recent glibc and they don't have uClibc. Chances