Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
playing with backreferences in list-colors
- X-seq: zsh-workers 9406
- From: Alexandre Duret-Lutz <duret_g@xxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: playing with backreferences in list-colors
- Date: 22 Jan 2000 18:17:55 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
I have been playing with list-colors to colorize
process listing and so on. This is quite fun.
The snipsets below show two problems I had
1) patterns containing letters don't seems to match;
2) backreferences when (x)# style patterns don't match make zsh segfault.
% zsh -f
phobos% unset {,Z}LS_COLO{,U}RS
phobos% autoload -U compinit; compinit; zmodload zsh/complist
phobos% zstyle ':completion:*' group-name ''
phobos% zstyle ':completion:*:files' list-colors '=(#b)(a)*=0=1'
phobos% setopt extendedglob
phobos% touch a{a,b,c}foo
phobos% ls a<TAB>
aafoo abfoo acfoo # nothing is highlighted
phobos% zstyle ':completion:*:files' list-colors '=(#b)(?)*=0=1'
phobos% ls a<TAB>
aafoo abfoo acfoo # first letters are highlighted
phobos% zstyle ':completion:*:files' list-colors '=(#b)a(*)=1=0'
phobos% ls a<TAB>
aafoo abfoo acfoo # nothing is highlighted
Can't I put letters in those patterns?
And now :
phobos% zstyle ':completion:*:files' list-colors '=(#b)(a)#*=1=0'
phobos% ls a<TAB>
zsh: segmentation fault (core dumped) zsh -f
(I know, `(a)#' is weird, but actualy I would like to be able
to write something like `(*/)#([^ ]*)*' at the end of the pattern
for my processes listings, to colorize only basename of processes)
(gdb) bt
#0 0x80a7a37 in ztrsub (t=0x40014c50 "",
s=0x40018001 <Address 0x40018001 out of bounds>)
at ../../last/Src/utils.c:2594
#1 0x8094d5c in pattryrefs (prog=0x40014a98, string=0x40014c58 "./aafoo",
nump=0x401e2150, begp=0x401e2160, endp=0x401e21a0)
at ../../last/Src/pattern.c:1382
#2 0x401de36e in putfilecol (c=0x401e2100, group=0x814d470 "files",
n=0x40014c58 "./aafoo", m=33204) at ../../../last/Src/Zle/complist.c:585
#3 0x401de92c in clprintm (g=0x814d670, mp=0x814d6e0, mc=0, ml=0, lastc=0,
width=8, path=0x40014c58 "./aafoo", buf=0xbffff308)
at ../../../last/Src/Zle/complist.c:703
[...]
Does string="./aafoo" in frame #1 means that `(#b)(a)#*' is matched
over "./aafoo" instead of only "aafoo"?
BTW zsh seems to go into troubles when such a pattern don't match :
~ % zsh -f
phobos% setopt extendedglob
phobos% [[ ab = (#b)(a)#* ]]
phobos% echo $match
a
phobos% [[ .ab = (#b)(a)#* ]]
phobos% echo $match
zsh: bad pattern: (
phobos% [[ ./ab = (#b)(a)#* ]]
phobos% echo $match
zsh: bad pattern: (
phobos% [[ ab = (#b)(a)#* ]]
phobos% echo $match
a
phobos% [[ aafoo = (#b)(a)#* ]]
phobos% echo $match
a
phobos% [[ .aafoo = (#b)(a)#* ]]
phobos% echo $match
O
phobos% [[ ./aafoo = (#b)(a)#* ]]
phobos% echo $match
O
phobos% [[ ./aaffffffffffffffffffffoo = (#b)(a)#* ]]
phobos% echo $match
f
phobos% [[ .ab = (#b)(a)#* ]]
zsh: segmentation fault (core dumped) zsh -f
(sometime it's faster to coredump)
(gdb) bt
#0 0x80a7a37 in ztrsub (t=0x40014fc1 "O\001@",
s=0x40018001 <Address 0x40018001 out of bounds>)
at ../../last/Src/utils.c:2594
#1 0x8094ed7 in pattryrefs (prog=0x810b650, string=0x400153f8 ".ab",
nump=0x0, begp=0x0, endp=0x0) at ../../last/Src/pattern.c:1417
#2 0x80949f0 in pattry (prog=0x810b650, string=0x400153f8 ".ab")
at ../../last/Src/pattern.c:1286
#3 0x805c025 in evalcond (state=0xbffff6c0) at ../../last/Src/cond.c:206
#4 0x8064407 in execcond (state=0xbffff6c0, do_exec=0)
at ../../last/Src/exec.c:2856
[...]
--
Alexandre Duret-Lutz
Messages sorted by:
Reverse Date,
Date,
Thread,
Author