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

Re: The (X) flag.



On Jun 28,  6:57am, Frank Terbeck wrote:
}
} Now I thought it might throw an error when a given pattern doesn't
} match:

No.  Failing to match the pattern is not an error, it's one of the
expected possible outcomes.

} However, I guess, I'm misunderstanding the manual. So, could someone
} please give an example of what this flag does?

The errors involved are lexical errors, that is, failures in tokenizing
the string.  I can't immediately think of one that affects ${var#pat},
but here's an obvious one with the (Q) flag:

    % foo="two ' matched ' quotes"
    % print ${(Q)foo}
    two  matched  quotes
    % foo="only one ' quote"
    % print ${(Q)foo}
    only one ' quote
    % print ${(XQ)foo}
    zsh: unmatched '
    % 



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