* color
@ 2023-02-04 0:21 Ray Andrews
2023-02-04 4:25 ` color Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: Ray Andrews @ 2023-02-04 0:21 UTC (permalink / raw)
To: Zsh Users
Bart, all:
Trying to get rid of the calls to typeset, I'm experimenting with
variations of the second line here:
...
VARIABLES+="${parameters[$1]} $( typeset -m -- ${(b)1} )"
VARIABLES+="${parameters[$1]} $1=${(Pq+)1}"
...
... there are only very minor differences except in one case and that's
'color':
2 /aWorking/Zsh/Source/Wk 0 $ . v; v _v_a* color
H color = ( [00]=none [01]=bold [02]=faint [03]=standout
[04]=underline [05]=blink ...
H color = 'none normal bg-blue 31 bold no-standout bg-magenta faint
no-underline bg ...
Al _v_abrev = ( sed -re 's/(^[^ ]*) ([^=]*)=(.*)/\1 \2 = \3/' -e
's/integer[ |-]/I/ ...
Al _v_abrev = 'sed -re s/(^[^ ]*) ([^=]*)=(.*)/\1 \2 = \3/ -e
s/integer[ |-]/I/ -e ...
... the second line doesn't show the parentheses around arrays and the
way of quoting the 'sed' string is slightly different, but no matter.
However the 'color' param prints completely differently, and no
variation on the second line changes that. Also, the color/colour param
seems to be the only variable that has this issue. No other param shows
what look like indexes "[00]" that way. All printing methods I know of
besides typeset -m show the second version of 'color' but it looks plain
wrong, the typeset version is 'obviously' correct. The untruncated
'color':
3 /aWorking/Zsh/Source/Wk 2 $ print -r $color
none normal bg-blue 31 bold no-standout bg-magenta faint no-underline
bg-cyan standout no-blink bg-white underline 33 41 01 blink no-reverse
bg-default 27 no-conceal reverse conceal 30 31 08 39 02 32 24 45 35 05
34 30 39 47 black 23 red green 43 yellow 36 blue magenta 37 cyan 03
white 44 35 default 40 28 07 46 04 33 37 40 22 34 42 00 30 30 25 49
bg-black 36 32 bg-red bg-green bg-yellow
... completely strange. Why is 'color' unique in this way? Can I do
anything about it? Without 'typeset' the function runs 4X faster, so I
prefer the second line above if possible. Even simply as a logic
problem can't see how the two displays of 'color' are related but of
course they must be.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: color
2023-02-04 0:21 color Ray Andrews
@ 2023-02-04 4:25 ` Bart Schaefer
2023-02-04 16:00 ` color Ray Andrews
0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2023-02-04 4:25 UTC (permalink / raw)
To: Ray Andrews; +Cc: Zsh Users
On Fri, Feb 3, 2023 at 4:23 PM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> Trying to get rid of the calls to typeset
The first thing you should do is try to get rid of the calls to "sed".
You'll be happier in the long run if you don't have to keep adding
increasingly baroque regular expressions.
> ... completely strange. Why is 'color' unique in this way?
It's not unique, it's an associative array. Variables like "commands"
(after loading from zsh/parameter module) will show up the same way.
You're going to have to have separate cases for each of
scalar/array/associative. To get both the keys and the values of an
associate array, you need ${(kv)aary}.
This set of threads has gone on long enough, the whole point of your
function is to show you parameter type information so start paying
attention to what's different about THAT and you'll make more
progress.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: color
2023-02-04 4:25 ` color Bart Schaefer
@ 2023-02-04 16:00 ` Ray Andrews
0 siblings, 0 replies; 3+ messages in thread
From: Ray Andrews @ 2023-02-04 16:00 UTC (permalink / raw)
To: zsh-users
On 2023-02-03 20:25, Bart Schaefer wrote:
> The first thing you should do is try to get rid of the calls to "sed".
> You'll be happier in the long run if you don't have to keep adding
> increasingly baroque regular expressions.
I'm happy with the condensation to single letter identifiers, it keeps
the display narrow and justified. I had thought/hoped/wanted 'typeset
-mp' to show them but it doesn't. And it makes it easy to see
patterns. Probably better done with native zsh replacements tho. I
have it so you can optionally view the entire string too. Very nice to
have that. Self-explaining output. This is zsh being friendly.
2 /aWorking/Zsh/Source/Wk 0 $ . v; v ,f z*
scalar: Z = /aWorking/Zsh
array: zle_bracketed_paste = ( $'\C-[[?2004h' $'\C-[[?2004l' )
scalar: ZSH_ARGZERO = zsh
scalar: ZSHBOOT = /aWorking/Zsh/Boot
scalar-readonly-tied-special: ZSH_EVAL_CONTEXT = toplevel:shfunc:cmdsubst
array-readonly-tied-special: zsh_eval_context = ( toplevel shfunc
cmdsubst )
scalar: ZSH_NAME = zsh
scalar: ZSH_PATCHLEVEL = debian/5.8-6+deb11u1
array-readonly-hide-hideval-special: zsh_scheduled_events = !hidden!
integer-readonly-special: ZSH_SUBSHELL = 1
scalar: ZSH_VERSION = 5.8
2 /aWorking/Zsh/Source/Wk 0 $ . v; v z*
S Z = /aWorking/Zsh
A zle_bracketed_paste = ( $'\C-[[?2004h' $'\C-[[?2004l' )
S ZSH_ARGZERO = zsh
S ZSHBOOT = /aWorking/Zsh/Boot
Srts ZSH_EVAL_CONTEXT = toplevel:shfunc:cmdsubst
Arts zsh_eval_context = ( toplevel shfunc cmdsubst )
S ZSH_NAME = zsh
S ZSH_PATCHLEVEL = debian/5.8-6+deb11u1
Arhvs zsh_scheduled_events = !hidden!
Irs ZSH_SUBSHELL = 1
S ZSH_VERSION = 5.8
> It's not unique, it's an associative array. Variables like "commands"
> (after loading from zsh/parameter module) will show up the same way.
Ok, I'll be on the lookout for others like that. There's a dozen AAs
but none of them display that way -- that I've seen. 'color' seemed
unique in how it displays.
> You're going to have to have separate cases for each of
> scalar/array/associative. To get both the keys and the values of an
> associate array, you need ${(kv)aary}.
Probably not worth the trouble, I was just trying to duplicate 'typeset
-m' output via other means and the alternate line I showed comes very
close. I've learned to avoid subshells if I can. In this case I was
just curious about 'print $color' and indeed 'print ${(kv)color}' shows
sensible output -- I should have known that -- but I'm not going to
attempt separate code for different types. 'typeset -m' is fine tho a
bit slower.
> This set of threads has gone on long enough, the whole point of your
> function is to show you parameter type information so start paying
> attention to what's different about THAT and you'll make more
> progress.
It's basically finished. I was just curious about 'colors'.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-04 16:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-04 0:21 color Ray Andrews
2023-02-04 4:25 ` color Bart Schaefer
2023-02-04 16:00 ` color Ray Andrews
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).