zsh-users
 help / color / mirror / code / Atom feed
* coloring substitution seems to eat next line.
@ 2022-11-10  0:43 Ray Andrews
  2022-11-10  8:02 ` Roman Perepelitsa
  0 siblings, 1 reply; 39+ messages in thread
From: Ray Andrews @ 2022-11-10  0:43 UTC (permalink / raw)
  To: Zsh Users

So I'm trying to replace a sed with native zsh code.  This stuff in 
inside a 'for' loop with 'aa' as the counter and  '$filter' is 'zsh':

     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:

     print "going in: $cc[aa]"

     cc[aa]=( 
${${cc[aa]}//(#b)((#i)${filter})/$'\e[31;1m'${match[1]}$'\e[0m'} )

     print "coming out: $cc[aa]"

... almost works but it seems to eat the next element of the array every 
now and then with no pattern that I can discern.

/aWorking/garbageZSH              colored
/usr/share/zsh                            colored
/aWorking/Zsh                            disappears going in but seems 
to be there going out , but not colored
/aWorking/Backup/Zsh                ditto
/aWorking/Zsh-55555                  colored
/aWorking/Zsh/Zsh-5.8                no color as with above
/usr/share/doc/zsh-common        ditto

... however if I make the output array different from the input array 
everything is fine.  But I've always had success with that sort of array 
being overwritten by some manipulation of itself, tho it seems 
dangerous.  sed has no issue with it.   Anyway, the expansion seems to 
interfere with the the clean separation of the elements that I'm hoping 
for.  Using a separate output array is fine, still I'm curious as to 
what's going on.  In particular the way some lines seem to disappear 
going 'in' -- I print the array element -- and get nothing at all, but 
there is output ... which seems impossible (tho it's never colorized).  
It seems the expansion/substitution is ignoring line endings or some 
such.   I don't doubt there's some logic to what's happening but I sure 
don't get it.  It hasta be line separated.






^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2022-11-17 16:03 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-10  0:43 coloring substitution seems to eat next line Ray Andrews
2022-11-10  8:02 ` Roman Perepelitsa
2022-11-10 18:25   ` Ray Andrews
2022-11-10 18:36     ` Roman Perepelitsa
2022-11-10 18:45       ` Ray Andrews
2022-11-10 18:54       ` Bart Schaefer
2022-11-10 19:28         ` Ray Andrews
2022-11-10 20:22           ` Bart Schaefer
2022-11-10 21:42             ` Ray Andrews
2022-11-10 21:51               ` Roman Perepelitsa
2022-11-11 17:24                 ` Ray Andrews
2022-11-10 22:47               ` Bart Schaefer
2022-11-10 23:07                 ` Ray Andrews
2022-11-10 23:27                   ` Bart Schaefer
2022-11-11 15:00                     ` Ray Andrews
2022-11-11 18:15                       ` Bart Schaefer
2022-11-11 18:50                         ` Ray Andrews
2022-11-11 19:25                           ` Bart Schaefer
2022-11-11 21:26                             ` Ray Andrews
2022-11-12  4:24                               ` Bart Schaefer
2022-11-12 14:03                                 ` Ray Andrews
2022-11-13 15:09                                   ` Ray Andrews
2022-11-14 14:12                                     ` Roman Perepelitsa
2022-11-14 17:08                                     ` Ray Andrews
2022-11-14 17:12                                       ` Roman Perepelitsa
2022-11-14 18:58                                         ` Ray Andrews
2022-11-14 20:00                                           ` Bart Schaefer
2022-11-14 23:25                                             ` Ray Andrews
2022-11-15 14:17                                               ` Belaboring substitution syntax Ray Andrews
2022-11-16  1:49                                                 ` Bart Schaefer
2022-11-16  2:54                                                   ` Ray Andrews
2022-11-16  6:26                                                     ` Bart Schaefer
2022-11-16 14:08                                                       ` Ray Andrews
2022-11-16 14:13                                                         ` Roman Perepelitsa
2022-11-17  2:31                                                           ` Bart Schaefer
2022-11-17  8:59                                                             ` Roman Perepelitsa
2022-11-17 16:02                                                               ` Ray Andrews
2022-11-16 20:46                                                       ` Ray Andrews
2022-11-16 10:32                                                   ` Roman Perepelitsa

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).