xiaoxiang781216 commented on code in PR #2903:
URL: https://github.com/apache/nuttx-apps/pull/2903#discussion_r1890571067


##########
nshlib/nsh_parse.c:
##########
@@ -714,22 +715,27 @@ static int nsh_execute(FAR struct nsh_vtbl_s *vtbl,
         {
           nsh_undirect(vtbl, save);
         }
+    }
 
-      /* Mark errors so that it is possible to test for non-zero return
-       * values in nsh scripts.
-       */
+close_redir:
 
-      if (ret < 0)
-        {
-          return nsh_saveresult(vtbl, true);
-        }
+  /* Closing fds opened for redirection if necessary */
+
+  if (vtbl->np.np_redir_out && param->file_out && fd_out > STDOUT_FILENO)
+    {
+      close(fd_out);
+    }
+
+  if (vtbl->np.np_redir_in && param->file_in && fd_in > STDIN_FILENO)

Review Comment:
   ```suggestion
     if (fd_in > STDIN_FILENO)
   ```



##########
nshlib/nsh_parse.c:
##########
@@ -714,22 +715,27 @@ static int nsh_execute(FAR struct nsh_vtbl_s *vtbl,
         {
           nsh_undirect(vtbl, save);
         }
+    }
 
-      /* Mark errors so that it is possible to test for non-zero return
-       * values in nsh scripts.
-       */
+close_redir:
 
-      if (ret < 0)
-        {
-          return nsh_saveresult(vtbl, true);
-        }
+  /* Closing fds opened for redirection if necessary */
+
+  if (vtbl->np.np_redir_out && param->file_out && fd_out > STDOUT_FILENO)

Review Comment:
   ```suggestion
     if (fd_out > STDOUT_FILENO)
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to