You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/03/30 19:47:43 UTC
[incubator-nuttx-apps] branch master updated: nsh: sh_main also support isctty = true
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 9730eaa nsh: sh_main also support isctty = true
9730eaa is described below
commit 9730eaad9ec5259916bb46304803334bf694f967
Author: ligd <li...@xiaomi.com>
AuthorDate: Sat Dec 18 00:02:40 2021 +0800
nsh: sh_main also support isctty = true
Signed-off-by: ligd <li...@xiaomi.com>
---
include/nshlib/nshlib.h | 21 +++++++++++++++++++
nshlib/nsh_system.c | 55 +++++++++++++++++++++++++++++++++++++++----------
system/nsh/sh_main.c | 2 +-
3 files changed, 66 insertions(+), 12 deletions(-)
diff --git a/include/nshlib/nshlib.h b/include/nshlib/nshlib.h
index 894e736..cea122b 100644
--- a/include/nshlib/nshlib.h
+++ b/include/nshlib/nshlib.h
@@ -214,6 +214,27 @@ int platform_user_verify(FAR const char *username, FAR const char *password);
int nsh_system(int argc, FAR char *argv[]);
+/****************************************************************************
+ * Name: nsh_system_ctty
+ *
+ * Description:
+ * This is the NSH-specific implementation of the standard system()
+ * command.
+ *
+ * NOTE:
+ * This difference with nsh_system: newconsole set isctty true
+ *
+ * Input Parameters:
+ * Standard task start-up arguments. Expects argc == 2 with argv[1] being
+ * the command to execute
+ *
+ * Returned Values:
+ * EXIT_SUCCESS or EXIT_FAILURE
+ *
+ ****************************************************************************/
+
+int nsh_system_ctty(int argc, FAR char *argv[]);
+
#undef EXTERN
#ifdef __cplusplus
}
diff --git a/nshlib/nsh_system.c b/nshlib/nsh_system.c
index 4804268..12bbed5 100644
--- a/nshlib/nsh_system.c
+++ b/nshlib/nsh_system.c
@@ -33,6 +33,27 @@
#include "nsh_console.h"
/****************************************************************************
+ * Static Functions
+ ****************************************************************************/
+
+static int nsh_system_(int argc, FAR char *argv[], int isctty)
+{
+ FAR struct console_stdio_s *pstate = nsh_newconsole(isctty);
+ int ret;
+
+ DEBUGASSERT(pstate != NULL);
+
+ /* Execute the session */
+
+ ret = nsh_session(pstate, false, argc, argv);
+
+ /* Exit upon return */
+
+ nsh_exit(&pstate->cn_vtbl, ret);
+ return ret;
+}
+
+/****************************************************************************
* Public Functions
****************************************************************************/
@@ -57,17 +78,29 @@
int nsh_system(int argc, FAR char *argv[])
{
- FAR struct console_stdio_s *pstate = nsh_newconsole(false);
- int ret;
-
- DEBUGASSERT(pstate != NULL);
-
- /* Execute the session */
-
- ret = nsh_session(pstate, false, argc, argv);
+ return nsh_system_(argc, argv, false);
+}
- /* Exit upon return */
+/****************************************************************************
+ * Name: nsh_system_ctty
+ *
+ * Description:
+ * This is the NSH-specific implementation of the standard system()
+ * command.
+ *
+ * NOTE:
+ * This difference with nsh_system: newconsole set isctty true
+ *
+ * Input Parameters:
+ * Standard task start-up arguments. Expects argc == 2 with argv[1] being
+ * the command to execute
+ *
+ * Returned Values:
+ * EXIT_SUCCESS or EXIT_FAILURE
+ *
+ ****************************************************************************/
- nsh_exit(&pstate->cn_vtbl, ret);
- return ret;
+int nsh_system_ctty(int argc, FAR char *argv[])
+{
+ return nsh_system_(argc, argv, true);
}
diff --git a/system/nsh/sh_main.c b/system/nsh/sh_main.c
index b17c5e7..38e4592 100644
--- a/system/nsh/sh_main.c
+++ b/system/nsh/sh_main.c
@@ -49,5 +49,5 @@ int main(int argc, FAR char *argv[])
* system() and popen() interfaces.
*/
- return nsh_system(argc, argv);
+ return nsh_system_ctty(argc, argv);
}