Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: The elements of enlightenment
On Mon, Dec 5, 2022 at 4:58 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> 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 ) )
This is the standard way of splitting the output of a command into
lines and dropping empty lines:
list=( ${(f)"$(setopt)"} )
This requires KSH_OPTION_PRINT, just like your code. It may not be the
best idea to write code that deals with options in a way that requires
specific options.
It's unlikely that you need to capture the output of setopt in the
first place given that there is $options associative array.
() {
local k v
local -A color=(on 32 off 33)
for k v in ${(kv)options}; do
printf '%-20s = \e[%sm%s\e[0m\n' $k ${color[$v]} $v
done
}
Dealing with options as an associative array is a lot easier than
dealing with text.
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author