NSH: Separate command line parsing from command execution. Add support for multiple, semicolone separated commands on each line
This commit is contained in:
parent
f1540e461c
commit
819a4b5779
@ -758,3 +758,9 @@
|
||||
apps/nshlib/Kconfig: Refactor some configuration dependencies: NSH
|
||||
features should debug on netutil selections; netutil selections
|
||||
should depend on networking selections. (2014-1-9).
|
||||
* apps/nshlib/nsh_command.c: Separate NSH command handling from NSH
|
||||
line parsing. This re-partitioning simplifies the logic and will
|
||||
enable some things to come (2014-1-10).
|
||||
* apps/nshlib/nsh_parse.c: Will now support multiple commands on a
|
||||
command line, each separated with a semi-colon (2014-1-10).
|
||||
|
||||
|
@ -269,6 +269,14 @@ config NSH_LINELEN
|
||||
The maximum length of one command line and of one output line.
|
||||
Default: 80
|
||||
|
||||
config NSH_DISABLE_SEMICOLON
|
||||
bool "Disable multiple commands per line"
|
||||
default n
|
||||
---help---
|
||||
By default, you can enter multiple NSH commands on a line with each
|
||||
command separated by a semicolon. You can disable this feature to
|
||||
save a little memory on FLASH challenged platforms.
|
||||
|
||||
config NSH_MAXARGUMENTS
|
||||
int "Maximum number of command arguments"
|
||||
default 6
|
||||
|
@ -40,8 +40,9 @@ include $(APPDIR)/Make.defs
|
||||
# NSH Library
|
||||
|
||||
ASRCS =
|
||||
CSRCS = nsh_init.c nsh_parse.c nsh_console.c nsh_script.c nsh_fscmds.c
|
||||
CSRCS += nsh_ddcmd.c nsh_proccmds.c nsh_mmcmds.c nsh_envcmds.c nsh_dbgcmds.c
|
||||
CSRCS = nsh_init.c nsh_parse.c nsh_console.c nsh_script.c
|
||||
CSRCS += nsh_command.c nsh_fscmds.c nsh_ddcmd.c nsh_proccmds.c nsh_mmcmds.c
|
||||
CSRCS += nsh_envcmds.c nsh_dbgcmds.c
|
||||
|
||||
ifeq ($(CONFIG_NFILE_STREAMS),0)
|
||||
CSRCS += nsh_stdsession.c
|
||||
|
@ -62,6 +62,9 @@ Command Overview
|
||||
(more negative values) correspond to higher priorities. The
|
||||
default niceness is 10.
|
||||
|
||||
Multiple commands per line. NSH will accept multiple commands per
|
||||
command line with each command separated with the semi-colon character (;).
|
||||
|
||||
Conditional Command Execution
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@ -998,6 +1001,12 @@ NSH-Specific Configuration Settings
|
||||
The maximum length of one command line and of one output line.
|
||||
Default: 80
|
||||
|
||||
* CONFIG_NSH_DISABLE_SEMICOLON
|
||||
By default, you can enter multiple NSH commands on a line with
|
||||
each command separated by a semicolon. You can disable this
|
||||
feature to save a little memory on FLASH challenged platforms.
|
||||
Default: n
|
||||
|
||||
* CONFIG_NSH_NESTDEPTH
|
||||
The maximum number of nested if-then[-else]-fi sequences that
|
||||
are permissable. Default: 3
|
||||
|
21
nshlib/nsh.h
21
nshlib/nsh.h
@ -340,6 +340,24 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Argument list size
|
||||
*
|
||||
* argv[0]: The command name.
|
||||
* argv[1]: The beginning of argument (up to CONFIG_NSH_MAXARGUMENTS)
|
||||
* argv[argc-3]: Possibly '>' or '>>'
|
||||
* argv[argc-2]: Possibly <file>
|
||||
* argv[argc-1]: Possibly '&' (if pthreads are enabled)
|
||||
* argv[argc]: NULL terminating pointer
|
||||
*
|
||||
* Maximum size is CONFIG_NSH_MAXARGUMENTS+5
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NSH_DISABLEBG
|
||||
# define MAX_ARGV_ENTRIES (CONFIG_NSH_MAXARGUMENTS+5)
|
||||
#else
|
||||
# define MAX_ARGV_ENTRIES (CONFIG_NSH_MAXARGUMENTS+4)
|
||||
#endif
|
||||
|
||||
/* strerror() produces much nicer output but is, however, quite large and
|
||||
* will only be used if CONFIG_NSH_STRERROR is defined. Note that the strerror
|
||||
* interface must also have been enabled with CONFIG_LIBC_STRERROR.
|
||||
@ -487,6 +505,7 @@ extern const char g_loginfailure[];
|
||||
extern const char g_nshprompt[];
|
||||
extern const char g_nshsyntax[];
|
||||
extern const char g_fmtargrequired[];
|
||||
extern const char g_fmtnomatching[];
|
||||
extern const char g_fmtarginvalid[];
|
||||
extern const char g_fmtargrange[];
|
||||
extern const char g_fmtcmdnotfound[];
|
||||
@ -551,6 +570,8 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline);
|
||||
|
||||
/* Application interface */
|
||||
|
||||
int nsh_command(FAR struct nsh_vtbl_s *vtbl, int argc, char *argv[]);
|
||||
|
||||
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||
int nsh_builtin(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
|
||||
FAR char **argv, FAR const char *redirfile, int oflags);
|
||||
|
@ -39,22 +39,11 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sched.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/version.h>
|
||||
|
||||
#include <apps/nsh.h>
|
||||
#ifdef CONFIG_NSH_BUILTIN_APPS
|
||||
# include <nuttx/binfmt/builtin.h>
|
||||
#endif
|
||||
|
||||
#include "nsh.h"
|
||||
#include "nsh_console.h"
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user