优化命令长度和空格检查的日志输出,更新最大命令长度的定义

This commit is contained in:
LokLiang
2025-03-27 14:47:37 +08:00
parent 17d8362e5c
commit 47f1db868f
2 changed files with 14 additions and 20 deletions

View File

@@ -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 (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"
"Command: '%s'",
_FILENAME(sh_reg->file),
sh_reg->line,
cmd->cmd);
}
SYS_LOG_WRN("cmd: Command length exceeds the maximum limit!\r\n"
"Defined in file: %s:%d\r\n"
"Command: '%s'",
_FILENAME(sh_reg->file),
sh_reg->line,
cmd->cmd);
return -1;
}
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"
"Command: '%s'",
_FILENAME(sh_reg->file),
sh_reg->line,
cmd->cmd);
}
SYS_LOG_WRN("cmd: Command cannot contain spaces!\r\n"
"Defined in file: %s:%d\r\n"
"Command: '%s'",
_FILENAME(sh_reg->file),
sh_reg->line,
cmd->cmd);
return -1;
}