nuttx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gn...@apache.org
Subject [incubator-nuttx-apps] 06/09: nshlib: Rename 'sh' command to 'source' command
Date Sun, 19 Apr 2020 14:07:20 GMT
This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit d307758c3cd40c1a537094ad23c256d523f95e43
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
AuthorDate: Sat Apr 18 21:57:26 2020 +0800

    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>
---
 nshlib/Kconfig       |  4 ++--
 nshlib/README.txt    | 16 ++++++++--------
 nshlib/nsh.h         |  4 ++--
 nshlib/nsh_command.c | 18 ++++++++++++------
 nshlib/nsh_fscmds.c  |  6 +++---
 nshlib/nsh_script.c  |  2 +-
 6 files changed, 28 insertions(+), 22 deletions(-)

diff --git a/nshlib/Kconfig b/nshlib/Kconfig
index a6aa790..6d8b130 100644
--- a/nshlib/Kconfig
+++ b/nshlib/Kconfig
@@ -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
diff --git a/nshlib/README.txt b/nshlib/README.txt
index 49ca81f..8c67779 100644
--- a/nshlib/README.txt
+++ b/nshlib/README.txt
@@ -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,
diff --git a/nshlib/nsh.h b/nshlib/nsh.h
index 96623f3..06e80cc 100644
--- a/nshlib/nsh.h
+++ b/nshlib/nsh.h
@@ -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 */
 
diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c
index da749a8..895ed6b 100644
--- a/nshlib/nsh_command.c
+++ b/nshlib/nsh_command.c
@@ -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
diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c
index 296e917..bd8a55f 100644
--- a/nshlib/nsh_fscmds.c
+++ b/nshlib/nsh_fscmds.c
@@ -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]);
 }
diff --git a/nshlib/nsh_script.c b/nshlib/nsh_script.c
index cf0d536..4a12b44 100644
--- a/nshlib/nsh_script.c
+++ b/nshlib/nsh_script.c
@@ -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.
                */
 


Mime
View raw message