zsh-users
 help / color / mirror / code / Atom feed
From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Kannan Varadhan <kvaradhan3@gmail.com>
Cc: Mikael Magnusson <mikachu@gmail.com>, Zsh Users <zsh-users@zsh.org>
Subject: Re: colorizing printfs
Date: Sun, 12 May 2024 08:44:41 +0200	[thread overview]
Message-ID: <CAN=4vMp6zmo0Rs4LdtKz-JtPiLFCganNtWxpbGdctOvXca7XkQ@mail.gmail.com> (raw)
In-Reply-To: <c7606614-3510-4e20-a2da-0e9e16a0605f@gmail.com>

On Sun, May 12, 2024 at 2:19 AM Kannan Varadhan <kvaradhan3@gmail.com> wrote:
>
> On 5/11/24 07:37, Roman Perepelitsa wrote:
> >
> >
> > That output is actually expected. The right curly must be escaped.
> >
> >     printf '%s.%s.%s\n' "${(%):-%F{blue\}%B}" "test" "${(%):-%b}${(%):-%f}"
>
> Yes, this works,
>
> Is this something that I missed in the documentation?

I don't know if it's documented but it makes sense if you consider
these examples:

    % print "${foo:-bar}baz"
    barbaz
    % print "${foo:-bar}baz}"
    barbaz}
    % print "${foo:-{bar}baz}"
    {barbaz}

"{" isn't special on its own unless it is preceded by "$". Thus, the
first "}" encountered after "${" marks the end of the expansion.

Roman.


  reply	other threads:[~2024-05-12  6:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-11  0:52 Kannan Varadhan
2024-05-11 14:26 ` Mikael Magnusson
2024-05-11 14:37   ` Roman Perepelitsa
2024-05-12  0:19     ` Kannan Varadhan
2024-05-12  6:44       ` Roman Perepelitsa [this message]
2024-05-13 20:53       ` Rick Bowen
2024-05-14  6:48     ` Stephane Chazelas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAN=4vMp6zmo0Rs4LdtKz-JtPiLFCganNtWxpbGdctOvXca7XkQ@mail.gmail.com' \
    --to=roman.perepelitsa@gmail.com \
    --cc=kvaradhan3@gmail.com \
    --cc=mikachu@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).