According to Jim Meyering on 1/13/2010 2:26 AM:
> The behavior of bash via /bin/sh (same for zsh and dash, though without
> the warning) is probably POSIX-conforming, but this example illustrates
> why it would be better to emulate openBSD's /bin/sh.
>
> * tests/misc/sort-version: Don't use <<- and indented here-doc contents.
> s/<<-/<</ and unindent the here-document contents. Otherwise,
> bash would ignore the indented delimiter and use EOF, thus silently
> skipping this test.
Actually, this was a regression caused by your conversion from space to
tab indentation. POSIX states: "If the redirection symbol is "<<-" , all
leading <tab> characters shall be stripped from input lines and the line
containing the trailing delimiter." So it is only _required_ to work with
tabs; using spaces gives arbitrary results.
> OpenBSD5.4's shell reported the failure:
> $ printf 'cat<<-x\n foo\n x\n'|sh
> sh: <stdin>[4]: here document `x' unclosed
> [Exit 1]
> by contrast, bash warns but still exits successfully:
> $ printf 'cat<<-x\n foo\n x\n'|bash && echo you lose
> bash: line 3: warning: here-document at line 1 delimited by \
> end-of-file (wanted `x')
> foo
> x
> you lose
As proof, bash behaves just fine when you obey POSIX:
$ printf 'cat <<-x\n\thi\n\tx\n'|bash && echo you lose
hi
We should mention this in the autoconf manual, so I'm pushing this. I'm
not (yet) sure whether the warning about unterminated here-doc was
introduced in bash 4.0 or bash 4.1, but I can also confirm that bash 3.2
is silent whereas bash 4.1 warns (but the warning is longer than 80
columns, so it is not a nice fit in the manual).
--
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden