MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / msh_exec

Function msh_exec

components/finsh/msh.c:541–614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539
540
541int msh_exec(char *cmd, rt_size_t length)
542{
543 int cmd_ret = 0;
544
545 /* strim the beginning of command */
546 while ((length > 0) && (*cmd == ' ' || *cmd == '\t'))
547 {
548 cmd++;
549 length--;
550 }
551
552 if (length == 0)
553 return 0;
554
555 /* Exec sequence:
556 * 1. built-in command
557 * 2. module(if enabled)
558 */
559 if (_msh_exec_cmd(cmd, length, &cmd_ret) == 0)
560 {
561 if(cmd_ret < 0)
562 {
563 rt_kprintf("%s: command failed %d.\n", cmd, cmd_ret);
564 }
565 return cmd_ret;
566 }
567#ifdef DFS_USING_POSIX
568#ifdef DFS_USING_WORKDIR
569 if (msh_exec_script(cmd, length) == 0)
570 {
571 return 0;
572 }
573#endif
574
575#ifdef RT_USING_MODULE
576 if (msh_exec_module(cmd, length) == 0)
577 {
578 return 0;
579 }
580#endif /* RT_USING_MODULE */
581
582#ifdef RT_USING_SMART
583 /* exec from msh_exec , debug = 0*/
584 /* _msh_exec_lwp return is pid , <= 0 means failed */
585 cmd_ret = _msh_exec_lwp(0, cmd, length);
586 if (cmd_ret > 0)
587 {
588 return 0;
589 }
590#endif /* RT_USING_SMART */
591#endif /* DFS_USING_POSIX */
592
593 /* truncate the cmd at the first space. */
594 {
595 char *tcmd;
596 tcmd = cmd;
597 while (*tcmd != ' ' && *tcmd != '\0')
598 {

Callers 6

finsh_thread_entryFunction · 0.85
msh_exec_scriptFunction · 0.85
systemFunction · 0.85
rw007_wifi_initFunction · 0.85
em_initFunction · 0.85
run_copyFunction · 0.85

Calls 5

_msh_exec_cmdFunction · 0.85
rt_kprintfFunction · 0.85
msh_exec_scriptFunction · 0.85
msh_exec_moduleFunction · 0.85
_msh_exec_lwpFunction · 0.85

Tested by

no test coverage detected