Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: '<<-' here-documents oddity with line continuation



2018-02-09 09:24:27 +0000, Peter Stephenson:
> On Fri, 9 Feb 2018 08:01:41 +0100
> Martijn Dekker <martijn@xxxxxxxx> wrote:
> > Meanwhile I would welcome opinions whether either or both of these
> > issues should be fixed unconditionally, or in emulation only -- and, if
> > the latter, what shell option to attach it to. POSIX_STRINGS maybe?
> 
> Thanks for the patch.
> 
> I think the question is whether existing users are more likely to be
> relying on this behaviour, or simply finding it confusing.  I'd actaully
> hazard the latter --- line continuation is more useful if it's doing
> something a bit more predictable --- so I'd be inclined just to include
> the patch.  But I expect there are arguments the other way.
[...]

I agree it makes sense of treating it as a minor compatibility
bug fix.

Note that there's also:

cat << EOF
foo
E\
OF

which zsh does differently from other shells (and that nobody
would ever do).

About order and token recognition to reply on Martijn's initial
report, note  that in:

echo "$(echo 'foo\
bar')"

Or

echo "$(cat << 'EOF'
foo\
bar
EOF
)"

The \<LF> is meant *not* to be treated as a line continuation.
bash fixed a bug recently for that (the latter used to output
"foobar", it's only fixed on the development branch).

So there has to be some level of tokenisation and parsing done
before line continuation is handled. It's not like in C where
it's done as one of the first steps of the pre-processing stage.



Messages sorted by: Reverse Date, Date, Thread, Author