nshlib: Rename 'sh' command to 'source' command
since this command change the parent environment variable and add new '.' command which has the same functionality as 'source' Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
9ab5e2ff45
commit
d307758c3c
@ -507,8 +507,8 @@ config NSH_DISABLE_SET
|
||||
bool "Disable set"
|
||||
default n
|
||||
|
||||
config NSH_DISABLE_SH
|
||||
bool "Disable sh"
|
||||
config NSH_DISABLE_SOURCE
|
||||
bool "Disable source"
|
||||
default n
|
||||
|
||||
config NSH_DISABLE_SHUTDOWN
|
||||
|
@ -1199,11 +1199,6 @@ o set [{+|-}{e|x|xe|ex}] [<name> <value>]
|
||||
nsh> echo $foobar
|
||||
foovalue
|
||||
|
||||
o sh <script-path>
|
||||
|
||||
Execute the sequence of NSH commands in the file referred
|
||||
to by <script-path>.
|
||||
|
||||
o shutdown [--reboot]
|
||||
|
||||
Shutdown and power off the system or, optionally, reset and reboot the
|
||||
@ -1218,6 +1213,11 @@ o sleep <sec>
|
||||
|
||||
Pause execution (sleep) of <sec> seconds.
|
||||
|
||||
o source <script-path>
|
||||
|
||||
Execute the sequence of NSH commands in the file referred
|
||||
to by <script-path>.
|
||||
|
||||
o telnetd
|
||||
|
||||
The Telnet daemon may be started either programmatically by calling
|
||||
@ -1496,9 +1496,9 @@ Command Dependencies on Configuration Settings
|
||||
!CONFIG_NSH_DISABLE_ROUTE && (CONFIG_NET_IPv4 || CONFIG_NET_IPv6)
|
||||
rptun CONFIG_RPTUN
|
||||
set CONFIG_NSH_VARS || !CONFIG_DISABLE_ENVIRON
|
||||
sh CONFIG_NFILE_STREAMS > 0 && !CONFIG_NSH_DISABLESCRIPT
|
||||
shutdown CONFIG_BOARDCTL_POWEROFF || CONFIG_BOARDCTL_RESET
|
||||
sleep --
|
||||
source CONFIG_NFILE_STREAMS > 0 && !CONFIG_NSH_DISABLESCRIPT
|
||||
test !CONFIG_NSH_DISABLESCRIPT
|
||||
telnetd CONFIG_NSH_TELNET && !CONFIG_NSH_DISABLE_TELNETD
|
||||
time ---
|
||||
@ -1541,8 +1541,8 @@ also allow it to squeeze into very small memory footprints.
|
||||
CONFIG_NSH_DISABLE_POWEROFF, CONFIG_NSH_DISABLE_PS, CONFIG_NSH_DISABLE_PUT,
|
||||
CONFIG_NSH_DISABLE_PWD, CONFIG_NSH_DISABLE_READLINK, CONFIG_NSH_DISABLE_REBOOT,
|
||||
CONFIG_NSH_DISABLE_RM, CONFIG_NSH_DISABLE_RPTUN, CONFIG_NSH_DISABLE_RMDIR,
|
||||
CONFIG_NSH_DISABLE_ROUTE, CONFIG_NSH_DISABLE_SET, CONFIG_NSH_DISABLE_SH,
|
||||
CONFIG_NSH_DISABLE_SHUTDOWN, CONFIG_NSH_DISABLE_SLEEP, CONFIG_NSH_DISABLE_TEST,
|
||||
CONFIG_NSH_DISABLE_ROUTE, CONFIG_NSH_DISABLE_SET, CONFIG_NSH_DISABLE_SHUTDOWN,
|
||||
CONFIG_NSH_DISABLE_SLEEP, CONFIG_NSH_DISABLE_SOURCE, CONFIG_NSH_DISABLE_TEST,
|
||||
CONFIG_NSH_DIABLE_TIME, CONFIG_NSH_DISABLE_TRUNCATE, CONFIG_NSH_DISABLE_UMOUNT,
|
||||
CONFIG_NSH_DISABLE_UNSET, CONFIG_NSH_DISABLE_URLDECODE, CONFIG_NSH_DISABLE_URLENCODE,
|
||||
CONFIG_NSH_DISABLE_USERADD, CONFIG_NSH_DISABLE_USERDEL, CONFIG_NSH_DISABLE_USLEEP,
|
||||
|
@ -1008,8 +1008,8 @@ int cmd_irqinfo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
int cmd_readlink(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
#endif
|
||||
#if CONFIG_NFILE_STREAMS > 0 && !defined(CONFIG_NSH_DISABLESCRIPT)
|
||||
# ifndef CONFIG_NSH_DISABLE_SH
|
||||
int cmd_sh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
# ifndef CONFIG_NSH_DISABLE_SOURCE
|
||||
int cmd_source(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
|
||||
# endif
|
||||
#endif /* CONFIG_NFILE_STREAMS && !CONFIG_NSH_DISABLESCRIPT */
|
||||
|
||||
|
@ -85,6 +85,12 @@ static int cmd_unrecognized(FAR struct nsh_vtbl_s *vtbl, int argc,
|
||||
|
||||
static const struct cmdmap_s g_cmdmap[] =
|
||||
{
|
||||
#if CONFIG_NFILE_STREAMS > 0 && !defined(CONFIG_NSH_DISABLESCRIPT)
|
||||
# ifndef CONFIG_NSH_DISABLE_SOURCE
|
||||
{ ".", cmd_source, 2, 2, "<script-path>" },
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_TEST)
|
||||
{ "[", cmd_lbracket, 4, CONFIG_NSH_MAXARGUMENTS, "<expression> ]" },
|
||||
#endif
|
||||
@ -478,12 +484,6 @@ static const struct cmdmap_s g_cmdmap[] =
|
||||
#endif
|
||||
#endif /* CONFIG_NSH_DISABLE_SET */
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0 && !defined(CONFIG_NSH_DISABLESCRIPT)
|
||||
# ifndef CONFIG_NSH_DISABLE_SH
|
||||
{ "sh", cmd_sh, 2, 2, "<script-path>" },
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NSH_DISABLE_SHUTDOWN
|
||||
#if defined(CONFIG_BOARDCTL_POWEROFF) && defined(CONFIG_BOARDCTL_RESET)
|
||||
{ "shutdown", cmd_shutdown, 1, 2, "[--reboot]" },
|
||||
@ -498,6 +498,12 @@ static const struct cmdmap_s g_cmdmap[] =
|
||||
{ "sleep", cmd_sleep, 2, 2, "<sec>" },
|
||||
#endif
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0 && !defined(CONFIG_NSH_DISABLESCRIPT)
|
||||
# ifndef CONFIG_NSH_DISABLE_SOURCE
|
||||
{ "source", cmd_source, 2, 2, "<script-path>" },
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_TEST)
|
||||
{ "test", cmd_test, 3, CONFIG_NSH_MAXARGUMENTS, "<expression>" },
|
||||
#endif
|
||||
|
@ -1671,12 +1671,12 @@ int cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cmd_sh
|
||||
* Name: cmd_source
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0 && !defined(CONFIG_NSH_DISABLESCRIPT)
|
||||
#ifndef CONFIG_NSH_DISABLE_SH
|
||||
int cmd_sh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
#ifndef CONFIG_NSH_DISABLE_SOURCE
|
||||
int cmd_source(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
return nsh_script(vtbl, argv[0], argv[1]);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
|
||||
if (pret)
|
||||
{
|
||||
/* Parse process the command. NOTE: this is recursive...
|
||||
* we got to cmd_sh via a call to nsh_parse. So some
|
||||
* we got to cmd_source via a call to nsh_parse. So some
|
||||
* considerable amount of stack may be used.
|
||||
*/
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user