mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-18 17:32:09 +08:00
apps/nshlib: If CONFIG_NSH_VARS=y, the NSH 'set' command with not argument will list all of the local NSH variables.
This commit is contained in:
@@ -124,6 +124,19 @@ static inline char *nsh_getdirpath(FAR struct nsh_vtbl_s *vtbl,
|
||||
return alloc;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nsh_dumpvar
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NSH_VARS) && !defined(CONFIG_NSH_DISABLE_SET)
|
||||
static int nsh_dumpvar(FAR struct nsh_vtbl_s *vtbl, FAR void *arg,
|
||||
FAR const char *pair)
|
||||
{
|
||||
nsh_output(vtbl, "%s\n", pair);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -336,8 +349,17 @@ int cmd_set(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
const char opts[] = NSH_NP_SET_OPTIONS;
|
||||
int op;
|
||||
|
||||
/* REVISIT: set with no arguments should show all of the NSH variables */
|
||||
#ifdef CONFIG_NSH_VARS
|
||||
/* Set with no arguments will show all of the NSH variables */
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
ret = nsh_foreach_var(vtbl, nsh_dumpvar, NULL);
|
||||
nsh_output(vtbl, "\n");
|
||||
return ret < 0 ? ERROR : OK;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef NSH_HAVE_VARS
|
||||
/* Support set [{+|-}{e|x|xe|ex}] [<name> <value>] */
|
||||
|
||||
|
Reference in New Issue
Block a user