WARNING: This server is unstable and will be retired in the next days. If you want to keep this forum available, please request immediately a migration on the Nabble Support forum. Forums that don't receive any migration request will be deleted forever.

 « Return to Thread: Internal 'echo' command doesn't handle I/O errors on close file

Re: Internal 'echo' command doesn't handle I/O errors on close file

by Chet Ramey :: Rate this Message:

| View in Thread

On 4/23/12 6:38 AM, Andrey Zaitsev wrote:

> Bash Version: 4.1
> Patch Level: 2
> Release Status: release
>
> Description:
> Internal 'echo' command doesn't handle I/O errors on close file when I try
> redirect
> standart output to mounted filesystem without free space.

This is hard for me to test, but see if the attached patch provides the
behavior you'd like.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@...    http://cnswww.cns.cwru.edu/~chet/

[redir-close.patch]

*** ../bash-4.2-patched/redir.c 2011-01-02 16:00:31.000000000 -0500
--- redir.c 2012-04-24 20:42:12.000000000 -0400
***************
*** 1092,1099 ****
  #if defined (BUFFERED_INPUT)
   check_bash_input (redirector);
!  close_buffered_fd (redirector);
  #else /* !BUFFERED_INPUT */
!  close (redirector);
  #endif /* !BUFFERED_INPUT */
  }
        break;
--- 1092,1101 ----
  #if defined (BUFFERED_INPUT)
   check_bash_input (redirector);
!  r = close_buffered_fd (redirector);
  #else /* !BUFFERED_INPUT */
!  r = close (redirector);
  #endif /* !BUFFERED_INPUT */
+  if (r < 0 && (flags & RX_INTERNAL) && (errno == EIO || errno == ENOSPC))
+    REDIRECTION_ERROR (r, errno, -1);
  }
        break;

 « Return to Thread: Internal 'echo' command doesn't handle I/O errors on close file