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

Re: Here-strings and $functions

On Jul 24,  2:45am, Bart Schaefer wrote:
} schaefer[505] foo() {
} function> <<<'This is a here-string'
} function> }
} schaefer[506] foo
} This is a here-string
} schaefer[507] functions[foo]=$functions[foo]
} schaefer[508] foo
} foo:1: command not found: is
} schaefer[509] functions foo
} foo () {
}         is a here-string'' <<< '''This'
} }
} Uhh, yeah.

This bug is subtle, and I'm not sure how to fix it, and I can't spend
any more time on it tonight as I must get up very early tomorrow ...

The complication is that this:

foo() {
	This is a string

gets converted internally into a REDIR_HERESTR, and so does the original
example with <<<.  But in the case of <<<, THE QUOTES ARE STILL PART OF
THE STRING, as \230 tokens.  For <<-, there are no quotes.  So when we
arrive in getredirs(), in the <<- case we need to insert quotes and then
call bslashquote(), but in the <<< case we only need to untokenize().

The only way to get this right is to know whether the original code was
really a here-string, or actually a full-fledged here-document; but
that information isn't passed down to getredirs() -- I'm not even sure
whether it's available in gettext2().

Otherwise we need to change the way <<< here-strings are parsed, so that
they're stored untokenized and with quotes stripped.

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

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