mirror of
https://github.com/sheumann/hush.git
synced 2025-01-14 12:30:40 +00:00
When using wordexp, only try to use the expand command
when something actually got expanded. Skip it otherwise. -Erik
This commit is contained in:
parent
78f57460f2
commit
1365bb7861
26
lash.c
26
lash.c
@ -941,20 +941,22 @@ static int expand_arguments(char *command)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert from char** (one word per string) to a simple char*,
|
if (expand_result.we_wordc > 0) {
|
||||||
* but don't overflow command which is BUFSIZ in length */
|
/* Convert from char** (one word per string) to a simple char*,
|
||||||
*command = '\0';
|
* but don't overflow command which is BUFSIZ in length */
|
||||||
while (i < expand_result.we_wordc && total_length < BUFSIZ) {
|
*command = '\0';
|
||||||
length=strlen(expand_result.we_wordv[i])+1;
|
while (i < expand_result.we_wordc && total_length < BUFSIZ) {
|
||||||
if (BUFSIZ-total_length-length <= 0) {
|
length=strlen(expand_result.we_wordv[i])+1;
|
||||||
error_msg(out_of_space);
|
if (BUFSIZ-total_length-length <= 0) {
|
||||||
return FALSE;
|
error_msg(out_of_space);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
strcat(command+total_length, expand_result.we_wordv[i++]);
|
||||||
|
strcat(command+total_length, " ");
|
||||||
|
total_length+=length;
|
||||||
}
|
}
|
||||||
strcat(command+total_length, expand_result.we_wordv[i++]);
|
wordfree (&expand_result);
|
||||||
strcat(command+total_length, " ");
|
|
||||||
total_length+=length;
|
|
||||||
}
|
}
|
||||||
wordfree (&expand_result);
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* Ok. They don't have a recent glibc and they don't have uClibc. Chances
|
/* Ok. They don't have a recent glibc and they don't have uClibc. Chances
|
||||||
|
26
sh.c
26
sh.c
@ -941,20 +941,22 @@ static int expand_arguments(char *command)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert from char** (one word per string) to a simple char*,
|
if (expand_result.we_wordc > 0) {
|
||||||
* but don't overflow command which is BUFSIZ in length */
|
/* Convert from char** (one word per string) to a simple char*,
|
||||||
*command = '\0';
|
* but don't overflow command which is BUFSIZ in length */
|
||||||
while (i < expand_result.we_wordc && total_length < BUFSIZ) {
|
*command = '\0';
|
||||||
length=strlen(expand_result.we_wordv[i])+1;
|
while (i < expand_result.we_wordc && total_length < BUFSIZ) {
|
||||||
if (BUFSIZ-total_length-length <= 0) {
|
length=strlen(expand_result.we_wordv[i])+1;
|
||||||
error_msg(out_of_space);
|
if (BUFSIZ-total_length-length <= 0) {
|
||||||
return FALSE;
|
error_msg(out_of_space);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
strcat(command+total_length, expand_result.we_wordv[i++]);
|
||||||
|
strcat(command+total_length, " ");
|
||||||
|
total_length+=length;
|
||||||
}
|
}
|
||||||
strcat(command+total_length, expand_result.we_wordv[i++]);
|
wordfree (&expand_result);
|
||||||
strcat(command+total_length, " ");
|
|
||||||
total_length+=length;
|
|
||||||
}
|
}
|
||||||
wordfree (&expand_result);
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* Ok. They don't have a recent glibc and they don't have uClibc. Chances
|
/* Ok. They don't have a recent glibc and they don't have uClibc. Chances
|
||||||
|
26
shell/lash.c
26
shell/lash.c
@ -941,20 +941,22 @@ static int expand_arguments(char *command)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert from char** (one word per string) to a simple char*,
|
if (expand_result.we_wordc > 0) {
|
||||||
* but don't overflow command which is BUFSIZ in length */
|
/* Convert from char** (one word per string) to a simple char*,
|
||||||
*command = '\0';
|
* but don't overflow command which is BUFSIZ in length */
|
||||||
while (i < expand_result.we_wordc && total_length < BUFSIZ) {
|
*command = '\0';
|
||||||
length=strlen(expand_result.we_wordv[i])+1;
|
while (i < expand_result.we_wordc && total_length < BUFSIZ) {
|
||||||
if (BUFSIZ-total_length-length <= 0) {
|
length=strlen(expand_result.we_wordv[i])+1;
|
||||||
error_msg(out_of_space);
|
if (BUFSIZ-total_length-length <= 0) {
|
||||||
return FALSE;
|
error_msg(out_of_space);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
strcat(command+total_length, expand_result.we_wordv[i++]);
|
||||||
|
strcat(command+total_length, " ");
|
||||||
|
total_length+=length;
|
||||||
}
|
}
|
||||||
strcat(command+total_length, expand_result.we_wordv[i++]);
|
wordfree (&expand_result);
|
||||||
strcat(command+total_length, " ");
|
|
||||||
total_length+=length;
|
|
||||||
}
|
}
|
||||||
wordfree (&expand_result);
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* Ok. They don't have a recent glibc and they don't have uClibc. Chances
|
/* Ok. They don't have a recent glibc and they don't have uClibc. Chances
|
||||||
|
Loading…
x
Reference in New Issue
Block a user