JianyuWang0623 commented on code in PR #2737:
URL: https://github.com/apache/nuttx-apps/pull/2737#discussion_r1807896564


##########
nshlib/nsh_fileapps.c:
##########
@@ -107,39 +106,46 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const 
char *cmd,
       goto errout_with_actions;
     }
 
-  /* Handle redirection of input */
-
-  if (redirfile_in)
+  if (exec)
     {
-      /* Set up to close open redirfile and set to stdin (0) */
+      /* Handle redirection of input */
 
-      ret = posix_spawn_file_actions_addopen(&file_actions, 0,
-                                             redirfile_in, O_RDONLY, 0);
-      if (ret != 0)
+      if (exec->file_in)
         {
-          nsh_error(vtbl, g_fmtcmdfailed, cmd,
-                     "posix_spawn_file_actions_addopen",
-                     NSH_ERRNO);
-          goto errout_with_actions;
+          /* Set up to close open redirfile and set to stdin (0) */
+
+          ret = posix_spawn_file_actions_addopen(&file_actions, 0,
+                                                 exec->file_in,
+                                                 exec->oflags_in,
+                                                 0);
+          if (ret != 0)
+            {
+              nsh_error(vtbl, g_fmtcmdfailed, cmd,
+                         "posix_spawn_file_actions_addopen",
+                         NSH_ERRNO);
+              goto errout_with_actions;
+            }
         }
-    }
 
-  /* Handle re-direction of output */
+      /* Handle re-direction of output */
 
-  if (redirfile_out)
-    {
-      ret = posix_spawn_file_actions_addopen(&file_actions, 1, redirfile_out,
-                                             oflags, 0644);
-      if (ret != 0)
+      if (exec->file_out)
         {
-          /* posix_spawn_file_actions_addopen returns a positive errno
-           * value on failure.
-           */
+          ret = posix_spawn_file_actions_addopen(&file_actions, 1,
+                                                 exec->file_out,
+                                                 exec->oflags_out,
+                                                 0644);
+          if (ret != 0)
+            {
+              /* posix_spawn_file_actions_addopen returns a positive errno
+               * value on failure.
+               */
 
-          nsh_error(vtbl, g_fmtcmdfailed, cmd,
-                     "posix_spawn_file_actions_addopen",
-                     NSH_ERRNO);
-          goto errout_with_attrs;
+              nsh_error(vtbl, g_fmtcmdfailed, cmd,
+                         "posix_spawn_file_actions_addopen",
+                         NSH_ERRNO);

Review Comment:
   done. thank you.



##########
nshlib/nsh_fileapps.c:
##########
@@ -107,39 +106,46 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const 
char *cmd,
       goto errout_with_actions;
     }
 
-  /* Handle redirection of input */
-
-  if (redirfile_in)
+  if (exec)
     {
-      /* Set up to close open redirfile and set to stdin (0) */
+      /* Handle redirection of input */
 
-      ret = posix_spawn_file_actions_addopen(&file_actions, 0,
-                                             redirfile_in, O_RDONLY, 0);
-      if (ret != 0)
+      if (exec->file_in)
         {
-          nsh_error(vtbl, g_fmtcmdfailed, cmd,
-                     "posix_spawn_file_actions_addopen",
-                     NSH_ERRNO);
-          goto errout_with_actions;
+          /* Set up to close open redirfile and set to stdin (0) */
+
+          ret = posix_spawn_file_actions_addopen(&file_actions, 0,
+                                                 exec->file_in,
+                                                 exec->oflags_in,
+                                                 0);
+          if (ret != 0)
+            {
+              nsh_error(vtbl, g_fmtcmdfailed, cmd,
+                         "posix_spawn_file_actions_addopen",

Review Comment:
   done. thank you.



-- 
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-unsubscr...@nuttx.apache.org

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

Reply via email to