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

Re: Block comments ala Ray



2021-02-12 21:02:36 +0000, Stephane Chazelas:
[...]
> as the parsing of the inside of `...` is deferred in all shells
> except ash-based ones; see $shell -c ':||echo `for`'. A bit like
> in eval 'echo x # comment'.
> 
> It's also deferred with the $(...) form in bash (but bash only
> AFAICT):
> 
> $ bash -c $'f() { echo $(echo x # comment\n); }; typeset -f f'
> f ()
> {
>     echo $(echo x # comment
> )
> }
[...]

Hmmm, actually in zsh, there is parsing going on there:

$ zsh -c 'f() { echo $(for); }; typeset -f f'
zsh: parse error near `)'
zsh:1: parse error near `$(for); }; typeset -...'

But still, the comments appear not to be discarded at that point:

$ zsh -c $'f() { echo $(echo x # comment\n); }; typeset -f f; f'
f () {
        echo $(echo x # comment
)
}
x

-- 
Stephane




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