mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-21 12:57:58 +02:00
136 lines
4.2 KiB
Plaintext
136 lines
4.2 KiB
Plaintext
*** ../bash-20101015/redir.c 2009-09-17 10:04:18.000000000 -0400
|
|
--- redir.c 2010-11-06 13:38:22.000000000 -0400
|
|
***************
|
|
*** 63,73 ****
|
|
|
|
extern int posixly_correct;
|
|
extern REDIRECT *redirection_undo_list;
|
|
extern REDIRECT *exec_redirection_undo_list;
|
|
|
|
/* Static functions defined and used in this file. */
|
|
- static void add_undo_close_redirect __P((int));
|
|
static void add_exec_redirect __P((REDIRECT *));
|
|
static int add_undo_redirect __P((int, enum r_instruction, int));
|
|
static int expandable_redirection_filename __P((REDIRECT *));
|
|
static int stdin_redirection __P((enum r_instruction, int));
|
|
--- 63,74 ----
|
|
|
|
extern int posixly_correct;
|
|
+ extern int last_command_exit_value;
|
|
extern REDIRECT *redirection_undo_list;
|
|
extern REDIRECT *exec_redirection_undo_list;
|
|
|
|
/* Static functions defined and used in this file. */
|
|
static void add_exec_redirect __P((REDIRECT *));
|
|
static int add_undo_redirect __P((int, enum r_instruction, int));
|
|
+ static int add_undo_close_redirect __P((int));
|
|
static int expandable_redirection_filename __P((REDIRECT *));
|
|
static int stdin_redirection __P((enum r_instruction, int));
|
|
***************
|
|
*** 94,97 ****
|
|
--- 95,105 ----
|
|
static int heredoc_errno;
|
|
|
|
+ #define REDIRECTION_ERROR(r, e) \
|
|
+ if ((r) != 0) \
|
|
+ { \
|
|
+ last_command_exit_value = EXECUTION_FAILURE;\
|
|
+ return ((e) == 0 ? EINVAL : (e));\
|
|
+ }
|
|
+
|
|
void
|
|
redirection_error (temp, error)
|
|
***************
|
|
*** 814,820 ****
|
|
/* Only setup to undo it if the thing to undo is active. */
|
|
if ((fd != redirector) && (fcntl (redirector, F_GETFD, 0) != -1))
|
|
! add_undo_redirect (redirector, ri, -1);
|
|
else
|
|
! add_undo_close_redirect (redirector);
|
|
}
|
|
|
|
--- 822,829 ----
|
|
/* Only setup to undo it if the thing to undo is active. */
|
|
if ((fd != redirector) && (fcntl (redirector, F_GETFD, 0) != -1))
|
|
! r = add_undo_redirect (redirector, ri, -1);
|
|
else
|
|
! r = add_undo_close_redirect (redirector);
|
|
! REDIRECTION_ERROR (r, errno);
|
|
}
|
|
|
|
***************
|
|
*** 919,925 ****
|
|
/* Only setup to undo it if the thing to undo is active. */
|
|
if ((fd != redirector) && (fcntl (redirector, F_GETFD, 0) != -1))
|
|
! add_undo_redirect (redirector, ri, -1);
|
|
else
|
|
! add_undo_close_redirect (redirector);
|
|
}
|
|
|
|
--- 928,935 ----
|
|
/* Only setup to undo it if the thing to undo is active. */
|
|
if ((fd != redirector) && (fcntl (redirector, F_GETFD, 0) != -1))
|
|
! r = add_undo_redirect (redirector, ri, -1);
|
|
else
|
|
! r = add_undo_close_redirect (redirector);
|
|
! REDIRECTION_ERROR(r, errno);
|
|
}
|
|
|
|
***************
|
|
*** 973,979 ****
|
|
/* Only setup to undo it if the thing to undo is active. */
|
|
if (fcntl (redirector, F_GETFD, 0) != -1)
|
|
! add_undo_redirect (redirector, ri, redir_fd);
|
|
else
|
|
! add_undo_close_redirect (redirector);
|
|
}
|
|
#if defined (BUFFERED_INPUT)
|
|
--- 983,990 ----
|
|
/* Only setup to undo it if the thing to undo is active. */
|
|
if (fcntl (redirector, F_GETFD, 0) != -1)
|
|
! r = add_undo_redirect (redirector, ri, redir_fd);
|
|
else
|
|
! r = add_undo_close_redirect (redirector);
|
|
! REDIRECTION_ERROR(r, errno);
|
|
}
|
|
#if defined (BUFFERED_INPUT)
|
|
***************
|
|
*** 1047,1052 ****
|
|
}
|
|
|
|
if ((flags & RX_UNDOABLE) && (fcntl (redirector, F_GETFD, 0) != -1))
|
|
! add_undo_redirect (redirector, ri, -1);
|
|
|
|
#if defined (COPROCESS_SUPPORT)
|
|
--- 1058,1065 ----
|
|
}
|
|
|
|
+ r = 0;
|
|
if ((flags & RX_UNDOABLE) && (fcntl (redirector, F_GETFD, 0) != -1))
|
|
! r = add_undo_redirect (redirector, ri, -1);
|
|
! REDIRECTION_ERROR (r, errno);
|
|
|
|
#if defined (COPROCESS_SUPPORT)
|
|
***************
|
|
*** 1165,1169 ****
|
|
/* Set up to close FD when we are finished with the current command
|
|
and its redirections. */
|
|
! static void
|
|
add_undo_close_redirect (fd)
|
|
int fd;
|
|
--- 1178,1182 ----
|
|
/* Set up to close FD when we are finished with the current command
|
|
and its redirections. */
|
|
! static int
|
|
add_undo_close_redirect (fd)
|
|
int fd;
|
|
***************
|
|
*** 1178,1181 ****
|
|
--- 1191,1196 ----
|
|
closer->next = redirection_undo_list;
|
|
redirection_undo_list = closer;
|
|
+
|
|
+ return 0;
|
|
}
|
|
|