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

Re: [regression] %2K prompt expansion no longer works



On 10/25/20, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> Mikael Magnusson wrote on Sat, 24 Oct 2020 16:21 +0200:
>> 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
>>
>
> Isn't this what Oliver just pointed out in another thread? —
>
> Oliver Kiddle wrote in 47491:
>> Regarding (1), I just noticed that a new D01prompt test case is failing
>> on FreeBSD because ${(%):-%F{2}} is not producing the same as
>> ${(%):-%F{green}}. This is a new test added just last month in 47352.
>>
>> This is down to TXT_ATTR_FG_TERMCAP being set for 2 but not for green.

It is, I'm not reading that thread though :).

-- 
Mikael Magnusson




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