aboutsummaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/shell/hush.c b/shell/hush.c
index afbc3ebec..1d5642260 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -8077,8 +8077,11 @@ static int internally_opened_fd(int fd, struct squirrel *sq)
8077 return 0; 8077 return 0;
8078} 8078}
8079 8079
8080/* squirrel != NULL means we squirrel away copies of stdin, stdout, 8080/* sqp != NULL means we squirrel away copies of stdin, stdout,
8081 * and stderr if they are redirected. */ 8081 * and stderr if they are redirected.
8082 * If redirection fails, return 1. This will make caller
8083 * skip command execution and restore already created redirect fds.
8084 */
8082static int setup_redirects(struct command *prog, struct squirrel **sqp) 8085static int setup_redirects(struct command *prog, struct squirrel **sqp)
8083{ 8086{
8084 struct redir_struct *redir; 8087 struct redir_struct *redir;
@@ -8109,7 +8112,7 @@ static int setup_redirects(struct command *prog, struct squirrel **sqp)
8109 * "cmd > <file" (2nd redirect starts too early) 8112 * "cmd > <file" (2nd redirect starts too early)
8110 */ 8113 */
8111 syntax_error("invalid redirect"); 8114 syntax_error("invalid redirect");
8112 continue; 8115 return 1;
8113 } 8116 }
8114 mode = redir_table[redir->rd_type].mode; 8117 mode = redir_table[redir->rd_type].mode;
8115 p = expand_string_to_string(redir->rd_filename, 8118 p = expand_string_to_string(redir->rd_filename,
@@ -8124,7 +8127,9 @@ static int setup_redirects(struct command *prog, struct squirrel **sqp)
8124 */ 8127 */
8125 return 1; 8128 return 1;
8126 } 8129 }
8127 if (newfd == redir->rd_fd && sqp) { 8130 if (newfd == redir->rd_fd && sqp
8131 && sqp != ERR_PTR /* not a redirect in "exec" */
8132 ) {
8128 /* open() gave us precisely the fd we wanted. 8133 /* open() gave us precisely the fd we wanted.
8129 * This means that this fd was not busy 8134 * This means that this fd was not busy
8130 * (not opened to anywhere). 8135 * (not opened to anywhere).