|
@@ -74,14 +74,57 @@ struct command help_command __command = {
|
74
|
74
|
* Start command shell
|
75
|
75
|
*
|
76
|
76
|
*/
|
77
|
|
-void shell ( void ) {
|
|
77
|
+int shell ( void ) {
|
78
|
78
|
char *line;
|
|
79
|
+ int rc = 0;
|
79
|
80
|
|
80
|
81
|
do {
|
81
|
82
|
line = readline ( shell_prompt );
|
82
|
83
|
if ( line ) {
|
83
|
|
- system ( line );
|
|
84
|
+ rc = system ( line );
|
84
|
85
|
free ( line );
|
85
|
86
|
}
|
86
|
87
|
} while ( shell_exit == 0 );
|
|
88
|
+ shell_exit = 0;
|
|
89
|
+
|
|
90
|
+ return rc;
|
|
91
|
+}
|
|
92
|
+
|
|
93
|
+/** "shell" options */
|
|
94
|
+struct shell_options {};
|
|
95
|
+
|
|
96
|
+/** "shell" option list */
|
|
97
|
+static struct option_descriptor shell_opts[] = {};
|
|
98
|
+
|
|
99
|
+/** "shell" command descriptor */
|
|
100
|
+static struct command_descriptor shell_cmd =
|
|
101
|
+ COMMAND_DESC ( struct shell_options, shell_opts, 0, 0,
|
|
102
|
+ "", "" );
|
|
103
|
+
|
|
104
|
+/**
|
|
105
|
+ * "shell" command
|
|
106
|
+ *
|
|
107
|
+ * @v argc Argument count
|
|
108
|
+ * @v argv Argument list
|
|
109
|
+ * @ret rc Return status code
|
|
110
|
+ */
|
|
111
|
+static int shell_exec ( int argc, char **argv ) {
|
|
112
|
+ struct shell_options opts;
|
|
113
|
+ int rc;
|
|
114
|
+
|
|
115
|
+ /* Parse options */
|
|
116
|
+ if ( ( rc = parse_options ( argc, argv, &shell_cmd, &opts ) ) != 0 )
|
|
117
|
+ return rc;
|
|
118
|
+
|
|
119
|
+ /* Start shell */
|
|
120
|
+ if ( ( rc = shell() ) != 0 )
|
|
121
|
+ return rc;
|
|
122
|
+
|
|
123
|
+ return 0;
|
87
|
124
|
}
|
|
125
|
+
|
|
126
|
+/** "shell" command */
|
|
127
|
+struct command shell_command __command = {
|
|
128
|
+ .name = "shell",
|
|
129
|
+ .exec = shell_exec,
|
|
130
|
+};
|