zsh-users
 help / color / mirror / code / Atom feed
* The elements of enlightenment
@ 2022-12-05 15:57 Ray Andrews
  2022-12-05 16:24 ` Roman Perepelitsa
  2022-12-06  6:39 ` Lawrence Velázquez
  0 siblings, 2 replies; 24+ messages in thread
From: Ray Andrews @ 2022-12-05 15:57 UTC (permalink / raw)
  To: Zsh Users

I  think I've finally actually figured out the reason that lines aren't 
elements and elements aren't lines even though they can print exactly 
the same:

     $ list=( $( setopt ) )

... We get word splitting and the option and the value 'print -l' on 
different lines and '$#list' is the count of the number of words/lines 
namely twice the number of options.  Good, fine, and understood.  But I 
want the option and it's value on the same line, just as if 'setopt' was 
executed at CLI.  By double quoting: ( "$( setopt )" ) we seem to have 
solved the problem, it prints correctly.  But trouble lurks in the 
shadows.   I do this:

     $  list=( "${list[@]/ off/${red} off${nrm}}" )

... And I'm baffled that only the very first 'off' is colorized. Why?  
Because '$#list' = 1!  It looks like we have each line as a separate 
element but we don't.  It only looks that way because the newlines in 
the output are still in there, they aren't 'print -l' newlines, they're 
newlines in the data itself!! They look the same but they are *not* the 
same.  To really get what it looks like I have I must first:

     $ list=( ${(f)list} )

NOW our element count is what we want it to be -- one per line and every 
'off' get colored.  Newlines aren't elements and elements aren't 
newlines.  Finally!  I'll never be fooled by appearances again.  Do I 
have this right?  Only took ten years :(




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

end of thread, other threads:[~2022-12-07  1:05 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-05 15:57 The elements of enlightenment Ray Andrews
2022-12-05 16:24 ` Roman Perepelitsa
2022-12-05 18:30   ` Bart Schaefer
2022-12-05 19:35   ` Ray Andrews
2022-12-05 19:44     ` Bart Schaefer
2022-12-05 19:58     ` Roman Perepelitsa
2022-12-05 21:20       ` Ray Andrews
2022-12-05 21:49         ` Roman Perepelitsa
2022-12-05 23:52           ` Ray Andrews
2022-12-06  0:17             ` Bart Schaefer
2022-12-06  1:34               ` Ray Andrews
2022-12-06 18:55             ` Roman Perepelitsa
2022-12-06 19:45               ` Bart Schaefer
2022-12-06 20:01                 ` Roman Perepelitsa
2022-12-06 20:07                   ` Bart Schaefer
2022-12-06 20:22                     ` Roman Perepelitsa
2022-12-06 23:52               ` Lawrence Velázquez
2022-12-07  1:04                 ` Lawrence Velázquez
2022-12-05 21:49         ` Bart Schaefer
2022-12-05 21:51           ` Bart Schaefer
2022-12-05 22:24           ` Ray Andrews
2022-12-05 23:24             ` Bart Schaefer
2022-12-06  1:47               ` Ray Andrews
2022-12-06  6:39 ` Lawrence Velázquez

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