[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible bug when combining Bash's process substitution with HERE-do
Re: Possible bug when combining Bash's process substitution with HERE-document?
Fri, 20 Jun 2014 08:20:43 -0400
On Fri, Jun 20, 2014 at 12:00:02AM +0200, Tim Friske wrote:
> While searching for an alternative I came up with the following code
> which does not work when I have the "shopt -os errexit" command line
> at the top of my script:
> read -d '' -r foobar <<BARFOO
> bla bla
read returns "failure" because it reaches end of file without
encountering the delimiter character (0x00).
This is why you don't use set -e (or errexit, or trap ERR, or any of
the other syntaxes by which this misfeature is invoked).
For more fun details, see http://mywiki.wooledge.org/BashFAQ/105
You may be amazed at how incredibly broken set -e actually is.
Bourne shell and C were developed at a time when it was NOT the
standard practice for programming languages to handle exceptions/errors
for you. You need to check the results of each operation yourself.