NSH: if # appears on line, need to comment ignore additinal commands on the line
This commit is contained in:
parent
44ea3903f9
commit
58424404f0
@ -196,7 +196,7 @@ static int nsh_parse_command(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline);
|
|||||||
|
|
||||||
static const char g_token_separator[] = " \t\n";
|
static const char g_token_separator[] = " \t\n";
|
||||||
#ifndef NSH_DISABLE_SEMICOLON
|
#ifndef NSH_DISABLE_SEMICOLON
|
||||||
static const char g_line_separator[] = "\";\n";
|
static const char g_line_separator[] = "\"#;\n";
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_NSH_ARGCAT
|
#ifdef CONFIG_NSH_ARGCAT
|
||||||
static const char g_arg_separator[] = "`$";
|
static const char g_arg_separator[] = "`$";
|
||||||
@ -2191,22 +2191,23 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline)
|
|||||||
np->np_loffs = (uint16_t)(working - cmdline);
|
np->np_loffs = (uint16_t)(working - cmdline);
|
||||||
#endif
|
#endif
|
||||||
/* A command may be terminated with a newline character, the end of the
|
/* A command may be terminated with a newline character, the end of the
|
||||||
* line, or a semicolon. NOTE that the set of delimiting characters
|
* line, a semicolon, or a '#' character. NOTE that the set of
|
||||||
* includes the quotation mark. We need to handle quotation marks here
|
* delimiting characters includes the quotation mark. We need to
|
||||||
* because a semicolon or newline character within a quoted string must
|
* handle quotation marks here because any other delimiter within a
|
||||||
* be ignored.
|
* quoted string must be treated as normal text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
len = strcspn(working, g_line_separator);
|
len = strcspn(working, g_line_separator);
|
||||||
ptr = working + len;
|
ptr = working + len;
|
||||||
|
|
||||||
/* Check for the last command on the line. This means that the none
|
/* Check for the last command on the line. This means that the none
|
||||||
* of the delimiting characters was found or that the newline character
|
* of the delimiting characters was found or that the newline or '#'
|
||||||
* was found. Anything after the newline character is ignored (there
|
* character was found. Anything after the newline or '#' character
|
||||||
* should not be anything.
|
* is ignored (there should not be anything after a newline, of
|
||||||
|
* course).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (*ptr == '\0' || *ptr == '\n')
|
if (*ptr == '\0' || *ptr == '\n' || *ptr == '#')
|
||||||
{
|
{
|
||||||
/* Parse the last command on the line */
|
/* Parse the last command on the line */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user