Fix sh.c for the glab case. I was messing things up for

single argument commands.  It should now work as expected...
 -Erik
This commit is contained in:
Eric Andersen 2001-03-09 01:24:02 +00:00
parent 3dbf1e877a
commit 01658a3eec
3 changed files with 18 additions and 15 deletions

11
lash.c
View File

@ -994,8 +994,8 @@ static int expand_arguments(char *command)
/* Convert from char** (one word per string) to a simple char*, /* Convert from char** (one word per string) to a simple char*,
* but don't overflow command which is BUFSIZ in length */ * but don't overflow command which is BUFSIZ in length */
*command = '\0';
if ( expand_result.gl_pathc > 1) { if ( expand_result.gl_pathc > 1) {
*command = '\0';
while (i < expand_result.gl_pathc && total_length < BUFSIZ) { while (i < expand_result.gl_pathc && total_length < BUFSIZ) {
length=strlen(expand_result.gl_pathv[i])+1; length=strlen(expand_result.gl_pathv[i])+1;
if (BUFSIZ-total_length-length <= 0) { if (BUFSIZ-total_length-length <= 0) {
@ -1078,11 +1078,12 @@ static int expand_arguments(char *command)
} else { } else {
/* Seems we got an un-expandable variable. So delete it. */ /* Seems we got an un-expandable variable. So delete it. */
char *next_dst; char *next_dst;
if ((next_dst=strpbrk(dst+1, " \t~`!$^&*()=|\\{}[];\"'<>?.")) != NULL) { if ((next_dst=strpbrk(dst+1, " \t~`!$^&*()=|\\{}[];\"'<>?.")) == NULL) {
/* Move stuff to the end of the string to accommodate filling next_dst=dst+1+strlen(dst);
* the created gap with the new stuff */
memmove(dst, next_dst, next_dst-dst);
} }
/* Move stuff to the end of the string to accommodate filling
* the created gap with the new stuff */
memmove(dst, next_dst, next_dst-dst);
} }
} }

11
sh.c
View File

@ -994,8 +994,8 @@ static int expand_arguments(char *command)
/* Convert from char** (one word per string) to a simple char*, /* Convert from char** (one word per string) to a simple char*,
* but don't overflow command which is BUFSIZ in length */ * but don't overflow command which is BUFSIZ in length */
*command = '\0';
if ( expand_result.gl_pathc > 1) { if ( expand_result.gl_pathc > 1) {
*command = '\0';
while (i < expand_result.gl_pathc && total_length < BUFSIZ) { while (i < expand_result.gl_pathc && total_length < BUFSIZ) {
length=strlen(expand_result.gl_pathv[i])+1; length=strlen(expand_result.gl_pathv[i])+1;
if (BUFSIZ-total_length-length <= 0) { if (BUFSIZ-total_length-length <= 0) {
@ -1078,11 +1078,12 @@ static int expand_arguments(char *command)
} else { } else {
/* Seems we got an un-expandable variable. So delete it. */ /* Seems we got an un-expandable variable. So delete it. */
char *next_dst; char *next_dst;
if ((next_dst=strpbrk(dst+1, " \t~`!$^&*()=|\\{}[];\"'<>?.")) != NULL) { if ((next_dst=strpbrk(dst+1, " \t~`!$^&*()=|\\{}[];\"'<>?.")) == NULL) {
/* Move stuff to the end of the string to accommodate filling next_dst=dst+1+strlen(dst);
* the created gap with the new stuff */
memmove(dst, next_dst, next_dst-dst);
} }
/* Move stuff to the end of the string to accommodate filling
* the created gap with the new stuff */
memmove(dst, next_dst, next_dst-dst);
} }
} }

View File

@ -994,8 +994,8 @@ static int expand_arguments(char *command)
/* Convert from char** (one word per string) to a simple char*, /* Convert from char** (one word per string) to a simple char*,
* but don't overflow command which is BUFSIZ in length */ * but don't overflow command which is BUFSIZ in length */
*command = '\0';
if ( expand_result.gl_pathc > 1) { if ( expand_result.gl_pathc > 1) {
*command = '\0';
while (i < expand_result.gl_pathc && total_length < BUFSIZ) { while (i < expand_result.gl_pathc && total_length < BUFSIZ) {
length=strlen(expand_result.gl_pathv[i])+1; length=strlen(expand_result.gl_pathv[i])+1;
if (BUFSIZ-total_length-length <= 0) { if (BUFSIZ-total_length-length <= 0) {
@ -1078,11 +1078,12 @@ static int expand_arguments(char *command)
} else { } else {
/* Seems we got an un-expandable variable. So delete it. */ /* Seems we got an un-expandable variable. So delete it. */
char *next_dst; char *next_dst;
if ((next_dst=strpbrk(dst+1, " \t~`!$^&*()=|\\{}[];\"'<>?.")) != NULL) { if ((next_dst=strpbrk(dst+1, " \t~`!$^&*()=|\\{}[];\"'<>?.")) == NULL) {
/* Move stuff to the end of the string to accommodate filling next_dst=dst+1+strlen(dst);
* the created gap with the new stuff */
memmove(dst, next_dst, next_dst-dst);
} }
/* Move stuff to the end of the string to accommodate filling
* the created gap with the new stuff */
memmove(dst, next_dst, next_dst-dst);
} }
} }