mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 15:15:44 +00:00
2008-04-08 Chris Johns <chrisj@rtems.org>
* libmisc/shell/shell.c: Copy the cmd line to a buffer to split into argv parts. Was using the command line history buffer so the history was being corrupted.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2008-04-08 Chris Johns <chrisj@rtems.org>
|
||||||
|
|
||||||
|
* libmisc/shell/shell.c: Copy the cmd line to a buffer to split
|
||||||
|
into argv parts. Was using the command line history buffer so the
|
||||||
|
history was being corrupted.
|
||||||
|
|
||||||
2008-04-03 Chris Johns <chrisj@rtems.org>
|
2008-04-03 Chris Johns <chrisj@rtems.org>
|
||||||
|
|
||||||
* libfs/src/nfsclient/src/librtemsNfs.h,
|
* libfs/src/nfsclient/src/librtemsNfs.h,
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ int rtems_shell_line_editor(
|
|||||||
break;
|
break;
|
||||||
case EOF:
|
case EOF:
|
||||||
if (output)
|
if (output)
|
||||||
fputc(out, '\n');
|
fputc('\n', out);
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
case '\f':
|
case '\f':
|
||||||
@@ -668,6 +668,7 @@ rtems_boolean rtems_shell_main_loop(
|
|||||||
int cmd;
|
int cmd;
|
||||||
int cmd_count = 1; /* assume a script and so only 1 command line */
|
int cmd_count = 1; /* assume a script and so only 1 command line */
|
||||||
char *cmds[RTEMS_SHELL_CMD_COUNT];
|
char *cmds[RTEMS_SHELL_CMD_COUNT];
|
||||||
|
char *cmd_argv;
|
||||||
int argc;
|
int argc;
|
||||||
char *argv[RTEMS_SHELL_MAXIMUM_ARGUMENTS];
|
char *argv[RTEMS_SHELL_MAXIMUM_ARGUMENTS];
|
||||||
rtems_boolean result = TRUE;
|
rtems_boolean result = TRUE;
|
||||||
@@ -769,11 +770,17 @@ rtems_boolean rtems_shell_main_loop(
|
|||||||
/*
|
/*
|
||||||
* Allocate the command line buffers.
|
* Allocate the command line buffers.
|
||||||
*/
|
*/
|
||||||
|
cmd_argv = malloc (RTEMS_SHELL_CMD_SIZE);
|
||||||
|
if (!cmd_argv) {
|
||||||
|
fprintf(stderr, "no memory for command line buffers\n" );
|
||||||
|
}
|
||||||
|
|
||||||
cmds[0] = calloc (cmd_count, RTEMS_SHELL_CMD_SIZE);
|
cmds[0] = calloc (cmd_count, RTEMS_SHELL_CMD_SIZE);
|
||||||
if (!cmds[0]) {
|
if (!cmds[0]) {
|
||||||
fprintf(stderr, "no memory for command line buffers\n" );
|
fprintf(stderr, "no memory for command line buffers\n" );
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
if (cmd_argv && cmds[0]) {
|
||||||
|
|
||||||
memset (cmds[0], 0, cmd_count * RTEMS_SHELL_CMD_SIZE);
|
memset (cmds[0], 0, cmd_count * RTEMS_SHELL_CMD_SIZE);
|
||||||
|
|
||||||
@@ -856,7 +863,8 @@ rtems_boolean rtems_shell_main_loop(
|
|||||||
* Run in a new shell task background. (unix &)
|
* Run in a new shell task background. (unix &)
|
||||||
* Resuming. A little bash.
|
* Resuming. A little bash.
|
||||||
*/
|
*/
|
||||||
if (!rtems_shell_make_args(cmds[cmd], &argc, argv,
|
memcpy (cmd_argv, cmds[cmd], RTEMS_SHELL_CMD_SIZE);
|
||||||
|
if (!rtems_shell_make_args(cmd_argv, &argc, argv,
|
||||||
RTEMS_SHELL_MAXIMUM_ARGUMENTS)) {
|
RTEMS_SHELL_MAXIMUM_ARGUMENTS)) {
|
||||||
shell_cmd = rtems_shell_lookup_cmd(argv[0]);
|
shell_cmd = rtems_shell_lookup_cmd(argv[0]);
|
||||||
if ( argv[0] == NULL ) {
|
if ( argv[0] == NULL ) {
|
||||||
@@ -878,9 +886,13 @@ rtems_boolean rtems_shell_main_loop(
|
|||||||
}
|
}
|
||||||
} while (result && shell_env->forever);
|
} while (result && shell_env->forever);
|
||||||
|
|
||||||
free (cmds[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmds[0])
|
||||||
|
free (cmds[0]);
|
||||||
|
if (cmd_argv)
|
||||||
|
free (cmd_argv);
|
||||||
|
|
||||||
if ( stdinToClose )
|
if ( stdinToClose )
|
||||||
fclose( stdinToClose );
|
fclose( stdinToClose );
|
||||||
if ( stdoutToClose )
|
if ( stdoutToClose )
|
||||||
|
|||||||
Reference in New Issue
Block a user