Fix escape char problem.

This commit is contained in:
Eric Andersen 2000-11-30 00:03:57 +00:00
parent 9bd71e8323
commit 8c2d3f46ab
3 changed files with 39 additions and 12 deletions

13
lash.c
View File

@ -797,10 +797,14 @@ static void globLastArgument(struct childProgram *prog, int *argcPtr,
/* we need to remove whatever \ quoting is still present */ /* we need to remove whatever \ quoting is still present */
src = dst = prog->argv[argc_l - 1]; src = dst = prog->argv[argc_l - 1];
while (*src) { while (*src) {
if (*src != '\\') if (*src == '\\') {
src++;
*dst++ = process_escape_sequence(&src);
} else {
*dst++ = *src; *dst++ = *src;
src++; src++;
} }
}
*dst = '\0'; *dst = '\0';
} else if (!rc) { } else if (!rc) {
argcAlloced += (prog->globResult.gl_pathc - i); argcAlloced += (prog->globResult.gl_pathc - i);
@ -812,11 +816,16 @@ static void globLastArgument(struct childProgram *prog, int *argcPtr,
}else{ }else{
src = dst = prog->argv[argc_l - 1]; src = dst = prog->argv[argc_l - 1];
while (*src) { while (*src) {
if (*src != '\\') if (*src == '\\') {
src++;
*dst++ = process_escape_sequence(&src);
} else {
*dst++ = *src; *dst++ = *src;
src++; src++;
} }
}
*dst = '\0'; *dst = '\0';
prog->globResult.gl_pathc=0; prog->globResult.gl_pathc=0;
if (flags==0) if (flags==0)
prog->globResult.gl_pathv=NULL; prog->globResult.gl_pathv=NULL;

13
sh.c
View File

@ -797,10 +797,14 @@ static void globLastArgument(struct childProgram *prog, int *argcPtr,
/* we need to remove whatever \ quoting is still present */ /* we need to remove whatever \ quoting is still present */
src = dst = prog->argv[argc_l - 1]; src = dst = prog->argv[argc_l - 1];
while (*src) { while (*src) {
if (*src != '\\') if (*src == '\\') {
src++;
*dst++ = process_escape_sequence(&src);
} else {
*dst++ = *src; *dst++ = *src;
src++; src++;
} }
}
*dst = '\0'; *dst = '\0';
} else if (!rc) { } else if (!rc) {
argcAlloced += (prog->globResult.gl_pathc - i); argcAlloced += (prog->globResult.gl_pathc - i);
@ -812,11 +816,16 @@ static void globLastArgument(struct childProgram *prog, int *argcPtr,
}else{ }else{
src = dst = prog->argv[argc_l - 1]; src = dst = prog->argv[argc_l - 1];
while (*src) { while (*src) {
if (*src != '\\') if (*src == '\\') {
src++;
*dst++ = process_escape_sequence(&src);
} else {
*dst++ = *src; *dst++ = *src;
src++; src++;
} }
}
*dst = '\0'; *dst = '\0';
prog->globResult.gl_pathc=0; prog->globResult.gl_pathc=0;
if (flags==0) if (flags==0)
prog->globResult.gl_pathv=NULL; prog->globResult.gl_pathv=NULL;

View File

@ -797,10 +797,14 @@ static void globLastArgument(struct childProgram *prog, int *argcPtr,
/* we need to remove whatever \ quoting is still present */ /* we need to remove whatever \ quoting is still present */
src = dst = prog->argv[argc_l - 1]; src = dst = prog->argv[argc_l - 1];
while (*src) { while (*src) {
if (*src != '\\') if (*src == '\\') {
src++;
*dst++ = process_escape_sequence(&src);
} else {
*dst++ = *src; *dst++ = *src;
src++; src++;
} }
}
*dst = '\0'; *dst = '\0';
} else if (!rc) { } else if (!rc) {
argcAlloced += (prog->globResult.gl_pathc - i); argcAlloced += (prog->globResult.gl_pathc - i);
@ -812,11 +816,16 @@ static void globLastArgument(struct childProgram *prog, int *argcPtr,
}else{ }else{
src = dst = prog->argv[argc_l - 1]; src = dst = prog->argv[argc_l - 1];
while (*src) { while (*src) {
if (*src != '\\') if (*src == '\\') {
src++;
*dst++ = process_escape_sequence(&src);
} else {
*dst++ = *src; *dst++ = *src;
src++; src++;
} }
}
*dst = '\0'; *dst = '\0';
prog->globResult.gl_pathc=0; prog->globResult.gl_pathc=0;
if (flags==0) if (flags==0)
prog->globResult.gl_pathv=NULL; prog->globResult.gl_pathv=NULL;