Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [regression] %2K prompt expansion no longer works
- X-seq: zsh-workers 47496
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [regression] %2K prompt expansion no longer works
- Date: Sat, 24 Oct 2020 16:21:09 +0200
- Archived-at: <https://zsh.org/workers/47496>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-10/CAHYJk3SPBJvnEhWDDifxRXw3t89p1XbJ08w1QZb_kQVWrRVK5Q%40mail.gmail.com>
- Authentication-results: zsh.org; iprev=pass (mail-io1-f50.google.com) smtp.remote-ip=209.85.166.50; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=CYvO2UCBVR2FzN0dP7+8u37qMQOEsByr5WCTmSIV9gg=; b=Jbj/yHGKMr23ksELGPk3m5MZq+KZuBpoFxB8g+r4jN78AZeg+u8a1vRSCh96P6yPJh qgEx6qoBwC4wK6ROZw6x+cQafhJVLVQ2fvPxNhEvIj0ttt2N7ZUtCybrO3MWgLmb4z4/ fbElHcr2pTyoDPJ0hIttAMg2u8wPNYmG4z0M5N9uhrHoy3Y7bi/NZt4S9/o+IzdnnzuL Urxi/Z8JyVUJn861fuqeWzDlXr2NRvuEvpGNood2yIuGYyRFerybwFknx4/j0+Q1FNeT 6zhI6rzXicqz9cwtIkiX83YvkzaYwYHh3B5gbTUcNBi7aHoDc0blRAo+zwdBsUTmQUVR g/ZA==
- In-reply-to: <20200830111346.xulnbxoqxduetnoz@chazelas.org>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- References: <20200830111346.xulnbxoqxduetnoz@chazelas.org>
- Sender: zsh-workers-request@xxxxxxx
On 8/30/20, Stephane Chazelas <stephane@xxxxxxxxxxxx> wrote:
> $ print -rnP %2K | hd
> 00000000 1b 5b 34 30 6d |.[40m|
> 00000005
>
> %K{2} is fine:
>
> $ print -rnP '%K{2}' | hd
> 00000000 1b 5b 34 32 6d |.[42m|
> 00000005
>
> Introduced by worker:30496
> (https://www.zsh.org/mla/workers/2012/msg00421.html
> 8a9b141652a0e4157056dc21e36a64ac712a7ee7 git commit).
>
> Oddly, the comment there:
>
>> Well, nobody objected so here's a version with de-duplicated
>> code. The previous patch broke %K, but it works now (passed 1
>> for is_fg on both paths).
>
> Actually describes the bug here. Looks like Mikael just missed a bit in
> that
> fix.
>
> Should be fixed with:
>
>
> diff --git a/Src/prompt.c b/Src/prompt.c
> index bc9734720..997327e18 100644
> --- a/Src/prompt.c
> +++ b/Src/prompt.c
> @@ -258,7 +258,7 @@ parsecolorchar(zattr arg, int is_fg)
> bv->fm--;
> }
> } else
> - arg = match_colour(NULL, 1, arg);
> + arg = match_colour(NULL, is_fg, arg);
> return arg;
> }
Just noticed that these [unposted] testcases don't pass. Added some
debugging prints and it turns out that %F{green} uses a different code
than specifying the number. Eg,
echo $F1 $F2 $F3 $F4 | cat -v
results in
^[[38;5;2m ^[[38;5;2m ^[[38;5;2m ^[[32m
(the results are equivalent if you explicitly set fg_start_code to
^[[38;5;, but the test case doesn't do that, and of course that might
not be what terminfo contains anyway.)
I think the correct fix is to not include F4 and K4 since they use
these definitions in the source code:
#define TC_COL_FG_START "\033[3"
#define TC_COL_BG_START "\033[4"
which will not match the others.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author