apps/system/nsh: Completes implementation of system() and popen() commands for the KERNEL build mode.
This commit is contained in:
parent
7d47671b9d
commit
3c4ca6a35e
@ -103,6 +103,18 @@
|
|||||||
# undef HAVE_DUMMY_SYMTAB
|
# undef HAVE_DUMMY_SYMTAB
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Check if we need to build in support for the system() and/or popen()
|
||||||
|
* functions. In the KERNEL build mode (only), NSH is build as a ELF
|
||||||
|
* program and must be capable of executing a single command provided
|
||||||
|
* on the command line.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#undef HAVE_NSH_COMMAND
|
||||||
|
#if (defined(CONFIG_SYSTEM_SYSTEM) || defined(CONFIG_SYSTEM_POPEN)) && \
|
||||||
|
defined(CONFIG_BUILD_KERNEL)
|
||||||
|
# define HAVE_NSH_COMMAND 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Check if we have met the BINFS requirement either via a board-provided
|
/* Check if we have met the BINFS requirement either via a board-provided
|
||||||
* symbol table, an application provided symbol table, or a dummy symbol
|
* symbol table, an application provided symbol table, or a dummy symbol
|
||||||
* table
|
* table
|
||||||
@ -161,18 +173,20 @@ extern const int CONFIG_SYSTEM_NSH_SYMTAB_COUNTNAME;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nsh_main
|
* Name: nsh_task
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This is the main logic for the case of the NSH task. It will perform
|
||||||
|
* one-time NSH initialization and start an interactive session on the
|
||||||
|
* current console device.
|
||||||
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_BUILD_KERNEL
|
static int nsh_task(void)
|
||||||
int main(int argc, FAR char *argv[])
|
|
||||||
#else
|
|
||||||
int nsh_main(int argc, char *argv[])
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if defined(HAVE_DUMMY_SYMTAB) || defined (CONFIG_SYSTEM_NSH_SYMTAB)
|
#if defined(HAVE_DUMMY_SYMTAB) || defined (CONFIG_SYSTEM_NSH_SYMTAB)
|
||||||
struct boardioc_symtab_s symdesc;
|
struct boardioc_symtab_s symdesc;
|
||||||
@ -256,3 +270,41 @@ int nsh_main(int argc, char *argv[])
|
|||||||
|
|
||||||
return exitval;
|
return exitval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nsh_main
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_BUILD_KERNEL
|
||||||
|
int main(int argc, FAR char *argv[])
|
||||||
|
#else
|
||||||
|
int nsh_main(int argc, char *argv[])
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/* There are two modes that NSH can be executed in:
|
||||||
|
*
|
||||||
|
* 1) As a normal, interactive shell. In this case, no arguments are
|
||||||
|
* expected on the command line. OR
|
||||||
|
* 2) As a single command processor. In this case, the single command is
|
||||||
|
* is provided in argv[1].
|
||||||
|
*
|
||||||
|
* NOTE: The latter mode is only available if CONFIG_BUILD_KERNEL=y. In
|
||||||
|
* that cause, this main() function will be build as a process. The process
|
||||||
|
* will be started with a command by the implementations of the system() and
|
||||||
|
* popen() interfaces.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_NSH_COMMAND
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
return nsh_system(argc, argv);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
return nsh_task();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user