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

Re: comment block curiosity



On Sun, Jan 3, 2021 at 9:10 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
>     alias startcomment=': <<COMMENTBLOCK'
>     alias endcomment='COMMENTBLOCK'

You're overthinking this a bit, Ray.

alias startcomment=': <<\endcomment'

The backslash prevents accidental expansion of command substitutions
etc. in the block.

> [...]
>     endcomment         # This is ignored [...]
>     COMMENTBLOCK       # This ends the comment.
>
> You'd think that "endcomment' would be the alias more likely to work but
> it doesn't.  Why?  Can it be fixed?

Aliases do not expand inside here-documents.  Even if they did, the
ending delimiter must be found literally.




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