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

comments in command/process substitution and (z) PE



zshmisc(1) documents for comments:

    In non-interactive shells, or in interactive shells with the
    INTERACTIVE_COMMENTS option set, a word beginning with the third
    character of the histchars parameter (`#' by default) causes that
    word and all the following characters up to a newline to be ignored.

` command substituion prematurely ends comments, and (z) reflects that.

    % setopt interactivecomments
    % echo `echo foo #bar` baz
    foo baz
    % print -l ${(z)${:-'echo `echo foo #bar` baz'}}
    echo
    `echo foo #bar`
    baz

$( command substitutions and parameter substitutions correctly do not
terminate the comment until the newline, but (z) PE parses the line
incorrectly.

    % echo $(echo foo #bar) baz
    cmdsubst>

    % print -l ${(z)${:-'echo $(echo foo #bar) baz'}}
    echo
    $(echo foo #bar)
    baz

    % cat < <(echo foo #bar) baz
    cmdsubst>

    % print -l ${(z)${:-'cat < <(echo foo #bar) baz'}}
    cat
    <
    <(echo foo #bar)
    baz

- Matthew Martin



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