Fix a bug that prevented %'s and \'s from being passed to the program

invoked.
from FreeBSD.
This commit is contained in:
yamt 2001-08-03 04:10:51 +00:00
parent 3f273dbe61
commit 69ecbbeb80

View File

@ -1,4 +1,4 @@
/* $NetBSD: do_command.c,v 1.7 2001/03/13 17:51:50 wiz Exp $ */
/* $NetBSD: do_command.c,v 1.8 2001/08/03 04:10:51 yamt Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
@ -22,7 +22,7 @@
#if 0
static char rcsid[] = "Id: do_command.c,v 2.12 1994/01/15 20:43:43 vixie Exp ";
#else
__RCSID("$NetBSD: do_command.c,v 1.7 2001/03/13 17:51:50 wiz Exp $");
__RCSID("$NetBSD: do_command.c,v 1.8 2001/08/03 04:10:51 yamt Exp $");
#endif
#endif
@ -133,14 +133,21 @@ child_process(e, u)
* command, and subsequent characters are the additional input to
* the command. Subsequent %'s will be transformed into newlines,
* but that happens later.
*
* If there are escaped %'s, remove the escape character.
*/
/*local*/{
int escaped = FALSE;
int ch;
char *p;
for (input_data = e->cmd; (ch = *input_data) != '\0';
input_data++) {
for (input_data = p = e->cmd; (ch = *input_data) != '\0';
input_data++, p++) {
if (p != input_data)
*p = ch;
if (escaped) {
if (ch == '%' || ch == '\\')
*--p = ch;
escaped = FALSE;
continue;
}
@ -149,10 +156,11 @@ child_process(e, u)
continue;
}
if (ch == '%') {
*input_data++ = '\0';
input_data++;
break;
}
}
*p = '\0';
}
/* fork again, this time so we can exec the user's command.