Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions components/finsh/msh.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
#include <rtthread.h>
#include <string.h>
#include <errno.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

宏内核这边,更建议使用 <sys/errno.h>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

宏内核这边,更建议使用 <sys/errno.h>

标准C库的标准error头文件是 errno.h

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这部分还是以#include <errno.h> 为主


#ifdef RT_USING_FINSH

Expand Down Expand Up @@ -483,7 +484,7 @@ int _msh_exec_lwp(int debug, char *cmd, rt_size_t length)

int msh_exec(char *cmd, rt_size_t length)
{
int cmd_ret;
int cmd_ret = 0;

/* strim the beginning of command */
while ((length > 0) && (*cmd == ' ' || *cmd == '\t'))
Expand Down Expand Up @@ -521,7 +522,8 @@ int msh_exec(char *cmd, rt_size_t length)
#ifdef RT_USING_SMART
/* exec from msh_exec , debug = 0*/
/* _msh_exec_lwp return is pid , <= 0 means failed */
if (_msh_exec_lwp(0, cmd, length) > 0)
cmd_ret = _msh_exec_lwp(0, cmd, length);
if (cmd_ret > 0)
{
return 0;
}
Expand All @@ -538,7 +540,16 @@ int msh_exec(char *cmd, rt_size_t length)
}
*tcmd = '\0';
}
rt_kprintf("%s: command not found.\n", cmd);
#ifdef RT_USING_SMART
if (cmd_ret == -EACCES)
{
rt_kprintf("%s: Permission denied.\n", cmd);
}
else
#endif
{
rt_kprintf("%s: command not found.\n", cmd);
}
return -1;
}

Expand Down