1
0
mirror of https://github.com/NevermindZZT/letter-shell.git synced 2025-01-21 10:02:54 +08:00

优化 变量作为参数时, 如果变量不存在, 命令直接返回; 命令组子命令允许返回值打印

This commit is contained in:
Letter 2024-07-31 22:01:42 +08:00
parent 0ce0255194
commit 03432e824c
4 changed files with 13 additions and 12 deletions

View File

@ -1,8 +1,8 @@
# letter shell 3.x
![version](https://img.shields.io/badge/version-3.2.2-brightgreen.svg)
![version](https://img.shields.io/badge/version-3.2.4-brightgreen.svg)
![standard](https://img.shields.io/badge/standard-c99-brightgreen.svg)
![build](https://img.shields.io/badge/build-2023.10.25-brightgreen.svg)
![build](https://img.shields.io/badge/build-2024.07.31-brightgreen.svg)
![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)
一个功能强大的嵌入式shell

View File

@ -47,7 +47,7 @@
*/
#define SHELL_CMD_GROUP_ITEM(_type, _name, _func, _desc, ...) \
{ \
.attr.value = SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(_type)|SHELL_CMD_DISABLE_RETURN, \
.attr.value = SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(_type), \
.data.cmd.name = #_name, \
.data.cmd.function = (int (*)())_func, \
.data.cmd.desc = #_desc, \

View File

@ -14,7 +14,7 @@
#include "shell_cfg.h"
#define SHELL_VERSION "3.2.3" /**< 版本号 */
#define SHELL_VERSION "3.2.4" /**< 版本号 */
/**

View File

@ -326,9 +326,11 @@ static size_t shellExtParseNumber(char *string)
*
* @param shell shell对象
* @param var
* @return size_t
* @param result
*
* @return int 0 --1
*/
static size_t shellExtParseVar(Shell *shell, char *var)
static int shellExtParseVar(Shell *shell, char *var, size_t *result)
{
ShellCommand *command = shellSeekCommand(shell,
var + 1,
@ -336,11 +338,12 @@ static size_t shellExtParseVar(Shell *shell, char *var)
0);
if (command)
{
return shellGetVarValue(shell, command);
*result = shellGetVarValue(shell, command);
return 0;
}
else
{
return 0;
return -1;
}
}
@ -371,8 +374,7 @@ int shellExtParsePara(Shell *shell, char *string, char *type, size_t *result)
}
else if (*string == '$' && *(string + 1))
{
*result = shellExtParseVar(shell, string);
return 0;
return shellExtParseVar(shell, string, result);
}
else if (*string)
{
@ -385,8 +387,7 @@ int shellExtParsePara(Shell *shell, char *string, char *type, size_t *result)
{
if (*string == '$' && *(string + 1))
{
*result = shellExtParseVar(shell, string);
return 0;
return shellExtParseVar(shell, string, result);
}
#if SHELL_SUPPORT_ARRAY_PARAM == 1
else if (type[0] == '[')