[Pkg-zsh-devel] Bug#613162: zsh: Loading colors script fails, bad set of key/value pairs

Benjamin Peter benjaminpeter at arcor.de
Sun Feb 13 16:46:16 UTC 2011


Hi Frank,

On 02/13/2011 04:50 PM, Frank Terbeck wrote:
> Yeah. I was a little quick about this. This only prints the number of 
> key-value pairs in the associative array. What we're actually looking
> for is this:
>
> % print ${#${(kv)color}}
>
> In any case, `4' is too low a value. what does this print?
>
> % printf '%s = '\''%s'\''\n' ${(kv)color} | sort
>    

Not sure if this does what it was inteded to.

$ printf '%s = '\''%s'\''\n' ${(kv)color} | sort
  = ''''''
' ${(kv)color} | sortnone = ''


When I just do the following I get

$ print ${(kv)color}
none

But I think I figured what you wanted.

Maybe this?

printf '%s = %s\n' ${(kv)color[*]} | sort

Anyway. I tried to to do some kind of single step printf debugging after 
your printf hints and added the files as an attachement. I hope it might 
be usefull to you, I just see there that the mapping at some point 
fails, and bg-blue seems to be associated with fg-red. "bg-blue = 
fg-red". Maybe some loop is missing a value and leads to an "uneven 
association".

What I did:

I added some printfs to the colors function.

called
$ unset -f colors
$ autoload -U colors
$ colors
and grabbed the ouput.

I fear the line numbers are rubbish but you can see the place in the 
colors file.

> Thanks, I'll take a look at it when I'm on the train.
>
>    

Godspeed.

>> What exactly does ${(kv)color} access? Is kv a value?

>> Those flags are used to access the keys and values of an associative
>> array:
>>
>> % foo=( bar baz beer booze zack zonk )
>> % print ${foo[zack]}
>> zonk
>> % print ${(k)foo}
>> zack bar beer
>> % print ${(v)foo}
>> zonk baz booze
>> % print ${(kv)foo}
>> zack zonk bar baz beer booze
>>      
Thanks for the insight. I get it.
>> The latter is used to initialise $colour (British) with the same values
>> as in $color (American).
>>      

You just got to love it when you have to solve those kind of problems in IT.


regards,

Benjamin.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: colors-debugged.txt
URL: <http://lists.alioth.debian.org/pipermail/pkg-zsh-devel/attachments/20110213/5d7a85be/attachment-0004.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: colors
URL: <http://lists.alioth.debian.org/pipermail/pkg-zsh-devel/attachments/20110213/5d7a85be/attachment-0005.txt>


More information about the Pkg-zsh-devel mailing list