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

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



Op 09-02-18 om 16:27 schreef Stephane Chazelas:
> Note that there's also:
> 
> cat << EOF
> foo
> E\
> OF
> 
> which zsh does differently from other shells (and that nobody
> would ever do).

IOW, all shells support line continuation within the terminating
delimiter except zsh. Eesh.

Somebody somewhere has probably done this. I'll see if I can rethink my
patch to fix this as well.

> 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).

(For the record, it looks like zsh handles both correctly with or
without the patch.)

> 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.

Yes, I did realise as I was figuring out this patch that I slightly got
the wrong idea in the initial report, as the gethere() conversion
function appears to depend on tokenisation having already happened.

- Martijn



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