优化命令长度和空格检查的日志输出,更新最大命令长度的定义
This commit is contained in:
@@ -317,29 +317,23 @@ static int _register_cmd_check_fn(sh_t *sh_hdl, const sh_cmd_reg_t *sh_reg, char
|
|||||||
|
|
||||||
if (strlen(cmd->cmd) >= CONFIG_SH_MAX_CMD_LEN)
|
if (strlen(cmd->cmd) >= CONFIG_SH_MAX_CMD_LEN)
|
||||||
{
|
{
|
||||||
if (sh_hdl && sh_hdl->disable_echo == 0)
|
SYS_LOG_WRN("cmd: Command length exceeds the maximum limit!\r\n"
|
||||||
{
|
"Defined in file: %s:%d\r\n"
|
||||||
SYS_LOG_WRN("cmd: Command length exceeds the maximum limit!\r\n"
|
"Command: '%s'",
|
||||||
"Defined in file: %s:%d\r\n"
|
_FILENAME(sh_reg->file),
|
||||||
"Command: '%s'",
|
sh_reg->line,
|
||||||
_FILENAME(sh_reg->file),
|
cmd->cmd);
|
||||||
sh_reg->line,
|
|
||||||
cmd->cmd);
|
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strchr(cmd->cmd, ' '))
|
if (strchr(cmd->cmd, ' '))
|
||||||
{
|
{
|
||||||
if (sh_hdl && sh_hdl->disable_echo == 0)
|
SYS_LOG_WRN("cmd: Command cannot contain spaces!\r\n"
|
||||||
{
|
"Defined in file: %s:%d\r\n"
|
||||||
SYS_LOG_WRN("cmd: Command cannot contain spaces!\r\n"
|
"Command: '%s'",
|
||||||
"Defined in file: %s:%d\r\n"
|
_FILENAME(sh_reg->file),
|
||||||
"Command: '%s'",
|
sh_reg->line,
|
||||||
_FILENAME(sh_reg->file),
|
cmd->cmd);
|
||||||
sh_reg->line,
|
|
||||||
cmd->cmd);
|
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_SH_MAX_CMD_LEN
|
#ifndef CONFIG_SH_MAX_CMD_LEN
|
||||||
#define CONFIG_SH_MAX_CMD_LEN ((CONFIG_SH_MAX_PARAM / 10) > 10 ? (CONFIG_SH_MAX_PARAM / 10) : 10) /* 最大单个命令长度(包含结束符 '\0' ) */
|
#define CONFIG_SH_MAX_CMD_LEN ((CONFIG_SH_MAX_LINE_LEN / 10) > 10 ? (CONFIG_SH_MAX_LINE_LEN / 10) : 10) /* 最大单个命令长度(包含结束符 '\0' ) */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct sh_obj_def sh_t;
|
typedef struct sh_obj_def sh_t;
|
||||||
@@ -102,7 +102,7 @@ typedef struct sh_cmd
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
sys_psnode_t *reg_node; // 注意时设置的节点
|
sys_psnode_t *reg_node; // 注册节点
|
||||||
const sh_cmd_t *cmd; // 命令数据
|
const sh_cmd_t *cmd; // 命令数据
|
||||||
const char *file; // 文件
|
const char *file; // 文件
|
||||||
int line; // 行号
|
int line; // 行号
|
||||||
|
|||||||
Reference in New Issue
Block a user