Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: vanishing spaces
On Sat, Mar 30, 2024 at 8:18 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> aptitude columnizes its output [...]
> ... I have reason to capture the output of several versions of
> aptitude searches into a variable. I hope 'eval' is the right way:
>
> output=$( eval $* ) # Save output to an array variable.
That's not an array variable, it's a string. You need
output=( $( ... ) )
for array assignment. However, simple array assignment is not what
you want there, or you'll end up with every word of the output in its
own element.
You might not need the "eval" there, because $( ... ) is already a
command substitution; you only need the "eval" if there are elements
of $* that you want further expanded. It may work to use just $(
"$@" )
> print -l $output
> i A glx-alternative-nvidia - allows the selection of NVIDIA as GLX provider
[etc]
> ... the nice columns disappear.
It would appear from "print -l" that you're trying to get each line of
the output into a separate array element. Is that correct?
I'm not sure from what you've shown us why you're losing the internal
spacing, unless perhaps aptitude is doing it because it's output is
not a terminal. What does
print -r -- "$( eval $* )"
show?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author