Update msh.c
fix msh_exec(char* cmd, rt_size_t length) bug
This commit is contained in:
parent
97508eb48e
commit
849130da2c
|
@ -257,16 +257,29 @@ int msh_exec(char* cmd, rt_size_t length)
|
|||
int cmd0_size = 0;
|
||||
cmd_function_t cmd_func;
|
||||
|
||||
while(*cmd == ' ')
|
||||
{
|
||||
cmd++;
|
||||
length--;
|
||||
}
|
||||
while ((cmd[cmd0_size] != ' ' && cmd[cmd0_size] != '\t') && cmd0_size < length)
|
||||
cmd0_size ++;
|
||||
|
||||
|
||||
/* try to get built-in command */
|
||||
if (cmd0_size == 0) return -1;
|
||||
cmd_func = msh_get_cmd(cmd, cmd0_size);
|
||||
if (cmd_func == RT_NULL)
|
||||
{
|
||||
#ifdef RT_USING_MODULE
|
||||
msh_exec_module(cmd, length);
|
||||
#else
|
||||
argv[0] = cmd;
|
||||
while(*cmd != ' ')
|
||||
{
|
||||
if (*cmd == 0) break;
|
||||
cmd++;
|
||||
}
|
||||
if (*cmd == ' ') *cmd = 0;
|
||||
rt_kprintf("%s: command not found.\n", argv[0]);
|
||||
#endif
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue