Skip to content

Commit d5388ba

Browse files
committed
fix shell command to use new input
1 parent de3b594 commit d5388ba

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

phpdbg_prompt.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,13 +663,29 @@ static PHPDBG_COMMAND(shell) /* {{{ */
663663
/* don't allow this to loop, ever ... */
664664
switch (param->type) {
665665
case STR_PARAM: {
666-
FILE *fd = VCWD_POPEN(param->str, "w");
667-
if (fd) {
666+
FILE *fd = NULL;
667+
char * program = NULL;
668+
669+
/* we expect an input, I hope we get one ! */
670+
if (input && input->start) {
671+
program = (char*) input->start;
672+
673+
if (memcmp(
674+
program, "shell", sizeof("shell")-1) == SUCCESS) {
675+
program += sizeof("shell")-1;
676+
} else program += sizeof("-")-1;
677+
678+
while (program && isspace(*program)) {
679+
program++;
680+
}
681+
} else program = param->str;
682+
683+
if ((fd=VCWD_POPEN((char*)program, "w"))) {
668684
/* do something perhaps ?? do we want input ?? */
669685
fclose(fd);
670686
} else {
671687
phpdbg_error(
672-
"Failed to execute %s", param->str);
688+
"Failed to execute %s", program);
673689
}
674690
} break;
675691

0 commit comments

Comments
 (0)