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

Re: quoting question





On Tue, Sep 12, 2023 at 3:07 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
On Tue, Sep 12, 2023 at 11:46 AM Jim <linux.tech.guy@xxxxxxxxx> wrote:
>
> Zsh quoting at times makes me wonder. Do quoting? Don't do quoting?
> The following case has me scratching my head.  Can someone explain what is
> going on?

This doesn't directly have to do with quoting, rather it has to do
with ${param} expansion and brace expansion.  The short answer is you
should never have unquoted { } inside the ${...}, because the first }
encountered is usually going to be interpreted as a match to the ${
and not to any other { in the string.  Where double-quoting gets
involved is because inside a double-quoted string, none of the pairs
of { } have been tokenized, so the lexer can't distinguish which of
the two }} is the actual end of the expansion.


For the fifth statement:

 print -- "Date and Time:  ${(%):-%D{%Y-%m-%d %H:%M:%S %Z}} Test"

The following works:

print -- "Date and Time:  ${(%):-"%D{%Y-%m-%d %H:%M:%S %Z}"} Test"

Is this the correct interpretation of your statement, or did I somehow put
a bandaid on it.

I appreciate your input.

Thanks and best regards,

Jim


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