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

Re: Multiline Anonymous Literal Strings

On Sep 28,  1:51pm, Chris Johnson wrote:
} Anyone know of a way to compose a long literal string without doing
} something like this?

The following requires "setopt multios" (which is the default, but a
few people turn it off):

alias mycommand=${(j: :)"${(f)$(<<<'print this is one string'
# This is a comment, but you cannot use unbalanced quotes in it
<<<'this is a more "     " spacey "     " string'
<<<'this is a third string')}"}

I believe it to be a parsing bug that the comment is not treated as
a comment until the command substution is executed, rather than when
it is "compiled", but it's the closest approximation to what you want
that you're going to find.

} In C, contiguous quoted strings are implicitly joined at a compile time

You darned young whippersnappers and your fancy-ANSI programming!  In
my day you ate your backslashes with your K&R, and liked them.
} In Perl and other languages, concatenation operators like ., &, and +
} are available.

And your point is?

The syntax of the shell language (which is only implemented by zsh, not
defined by it) precludes the use of infix operators.

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