Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: coloring substitution seems to eat next line.
On Thu, Nov 10, 2022 at 1:44 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> cc[$aa]=$( print -r $cc[$aa] | sed -rn
> "s/($filter)/\x1b\[$color;1m\1\x1b\[0m/${sed_case}gp" )
>
> ... that's the sed version working fine. But this:
>
> cc[aa]=(
> ${${cc[aa]}//(#b)((#i)${filter})/$'\e[31;1m'${match[1]}$'\e[0m'} )
Differences in the second version compared to the first:
- aa instead of $aa
- slice assignment instead of scalar (almost certainly unintended)
- hardcoded (#i) instead of $sed_case
- hardcoded 31 instead of $color
- $filter treated as a literal instead of regex
Given that the second version works without errors, I assume that cc
must be a regular (not associative) array. This means you can replace
the whole loop with this:
local MATCH MBEGIN MEND
cc=(${cc//(#m)$~zsh_case$filter/$'\e[31;1m'$MATCH$'\e[0m'})
Here's a test:
() {
emulate -L zsh -o extended_glob
local cc=(/foo/Zsh/bar /baz /ZSHzsh /zsh-zsh)
local filter=zsh
local zsh_case='(#i)'
local MATCH MBEGIN MEND
cc=(${cc//(#m)$~zsh_case$filter/$'\e[31;1m'$MATCH$'\e[0m'})
print -rC1 -- ${(qqqq)cc}
print -rC1 -- $cc
}
> /aWorking/Zsh disappears going in but seems
> to be there going out , but not colored
You can debug this by printing all relevant parameters.
print -r -- "going in: $cc[aa]"
typeset -p cc aa filter
...
typeset -p cc
print -r -- "coming out: $cc[aa]"
After that you can reproduce and dissect the issue in isolation. You
can also ask other people for help and give them everything they need
to reproduce the problem.
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author