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

Re: bug report: INTERACTIVECOMMENTS option interacts oddly with shell functions in an interactive context



On Sun, Aug 29, 2021 at 1:58 PM Glyph <glyph@xxxxxxxxxxxxxxxxx> wrote:
>
> Comments in sample_function are interpreted normally, but comments *inside* the "bogus" expression will be interpreted as executing in an interactive context

Hm, well, this is quite obviously intentional based on the code that
interprets $(...) expressions.  The only way I can think of to change
it without breaking the behavior of $(...) typed at the actual command
line, would be for "source" and related operations to put
INTERACTIVECOMMENTS into the "sticky" emulation context during parsing
of the file (even if it was off in the parent shell).

That is, if "source" et al. always behaved as if

emulate $(emulate) -o interactivecomments -c 'source ...'

then comments in $(...) and related contexts would be ignored as if
they were parsed during the "source" command instead of during the
execution of the substitution.

But that could have some pretty confusing side-effects for functions
that want to examine $options (for example).

Incidentally, you almost certainly want

setopt LOCALOPTIONS INTERACTIVECOMMENTS

in any functions where you intend to put comments inside $(...),
otherwise you will propagate INTERACTIVECOMMENTS into the parent
shell.




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