Print expanded variables if -x

This commit is contained in:
David Sidrane 2017-04-05 18:31:47 -06:00 committed by Gregory Nutt
parent d03aa9112e
commit 35cf98d4df
3 changed files with 10 additions and 5 deletions

View File

@ -692,7 +692,7 @@
#ifndef CONFIG_NSH_DISABLESCRIPT
# define NSH_NP_SET_OPTIONS "ex" /* Maintain order see nsh_npflags_e */
# define NSH_NP_SET_OPTIONS_INIT (NSH_PFALG_SILENT)
# define NSH_NP_SET_OPTIONS_INIT (NSH_PFLAG_SILENT)
#endif
#if defined(CONFIG_DISABLE_ENVIRON) && defined(CONFIG_NSH_DISABLESCRIPT)
@ -758,9 +758,9 @@ struct nsh_loop_s
enum nsh_npflags_e
{
NSH_PFALG_IGNORE = 1, /* set for +e no exit on errors,
NSH_PFLAG_IGNORE = 1, /* set for +e no exit on errors,
* cleared -e exit on error */
NSH_PFALG_SILENT = 2, /* cleared -x print a trace of commands
NSH_PFLAG_SILENT = 2, /* cleared -x print a trace of commands
* when parsing.
* set +x no print a trace of commands */
};

View File

@ -1169,6 +1169,11 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline,
envstr = nsh_envexpand(vtbl, ptr);
if ((vtbl->np.np_flags & NSH_PFLAG_SILENT) == 0)
{
nsh_output(vtbl," %s=%s\n", ptr, envstr ? envstr :"(null)");
}
/* Concatenate the result of the operation with the accumulated
* string. On failures to allocation memory, nsh_strcat will
* just return value value of argument

View File

@ -136,7 +136,7 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
* considerable amount of stack may be used.
*/
if ((vtbl->np.np_flags & NSH_PFALG_SILENT) == 0)
if ((vtbl->np.np_flags & NSH_PFLAG_SILENT) == 0)
{
nsh_output(vtbl,"%s", buffer);
}
@ -144,7 +144,7 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
ret = nsh_parse(vtbl, buffer);
}
}
while (pret && (ret == OK || (vtbl->np.np_flags & NSH_PFALG_IGNORE)));
while (pret && (ret == OK || (vtbl->np.np_flags & NSH_PFLAG_IGNORE)));
/* Close the script file */