You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/07/21 08:51:13 UTC

[GitHub] [incubator-nuttx-apps] pkarashchenko commented on a diff in pull request #1224: nshlib:support nsh can redirect

pkarashchenko commented on code in PR #1224:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1224#discussion_r926422866


##########
nshlib/nsh_script.c:
##########
@@ -25,10 +25,44 @@
 #include <nuttx/config.h>
 
 #include "nsh.h"
+#include <fcntl.h>

Review Comment:
   please move this above `#include "nsh.h"`



##########
nshlib/nsh_script.c:
##########
@@ -25,10 +25,44 @@
 #include <nuttx/config.h>
 
 #include "nsh.h"
+#include <fcntl.h>
 #include "nsh_console.h"
 
 #if defined(CONFIG_FILE_STREAM) && !defined(CONFIG_NSH_DISABLESCRIPT)
 
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#if defined(CONFIG_NSH_ROMFSETC) || defined(CONFIG_NSH_ROMFSRC)
+static int nsh_script_redirect(FAR struct nsh_vtbl_s *vtbl,
+                               FAR const char *cmd,
+                               FAR const char *path)
+{
+  uint8_t save[SAVE_SIZE];
+  int fd = -1;
+  int ret;
+
+  if (CONFIG_NSH_SCRIRT_REDIRECT_PATH[0])
+    {
+      fd = open(CONFIG_NSH_SCRIRT_REDIRECT_PATH, 0666);
+      if (fd > 0)
+        {
+          nsh_redirect(vtbl, fd, save);
+        }
+    }
+
+  ret = nsh_script(vtbl, cmd, path);
+  if (fd >= 0)

Review Comment:
   let's use the same condition here and at line 49



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org