diff options
author | Michael Brown <mcb30@ipxe.org> | 2010-11-28 21:09:33 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2010-11-28 21:09:33 +0000 |
commit | 1fcea25c429472adaf498bb8a10fbe67b31c10dc (patch) | |
tree | 748d79f19fb96d2da4462fc0f91b89771bf043c3 /src/hci/shell.c | |
parent | 719f2d793ced4dc22d632303f78f01f1ae64836e (diff) | |
download | ipxe-1fcea25c429472adaf498bb8a10fbe67b31c10dc.tar.gz |
[shell] Add "shell" command
The "shell" command allows a script to enter an interactive shell,
which is potentially useful for troubleshooting.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/hci/shell.c')
-rw-r--r-- | src/hci/shell.c | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/src/hci/shell.c b/src/hci/shell.c index f9cd3af28..7bf138a2e 100644 --- a/src/hci/shell.c +++ b/src/hci/shell.c @@ -74,14 +74,57 @@ struct command help_command __command = { * Start command shell * */ -void shell ( void ) { +int shell ( void ) { char *line; + int rc = 0; do { line = readline ( shell_prompt ); if ( line ) { - system ( line ); + rc = system ( line ); free ( line ); } } while ( shell_exit == 0 ); + shell_exit = 0; + + return rc; +} + +/** "shell" options */ +struct shell_options {}; + +/** "shell" option list */ +static struct option_descriptor shell_opts[] = {}; + +/** "shell" command descriptor */ +static struct command_descriptor shell_cmd = + COMMAND_DESC ( struct shell_options, shell_opts, 0, 0, + "", "" ); + +/** + * "shell" command + * + * @v argc Argument count + * @v argv Argument list + * @ret rc Return status code + */ +static int shell_exec ( int argc, char **argv ) { + struct shell_options opts; + int rc; + + /* Parse options */ + if ( ( rc = parse_options ( argc, argv, &shell_cmd, &opts ) ) != 0 ) + return rc; + + /* Start shell */ + if ( ( rc = shell() ) != 0 ) + return rc; + + return 0; } + +/** "shell" command */ +struct command shell_command __command = { + .name = "shell", + .exec = shell_exec, +}; |