zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: vanishing spaces
Date: Sat, 30 Mar 2024 09:07:00 -0700	[thread overview]
Message-ID: <CAH+w=7ZFScinPmH9U-V0fjP1HdJJqSQJ4JHVFuwzT5NWiz=pFw@mail.gmail.com> (raw)
In-Reply-To: <3643c571-5830-420c-9d1f-88a6bf22cc0e@eastlink.ca>

On Sat, Mar 30, 2024 at 8:18 AM Ray Andrews <rayandrews@eastlink.ca> 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?


  reply	other threads:[~2024-03-30 16:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-30 15:18 Ray Andrews
2024-03-30 16:07 ` Bart Schaefer [this message]
2024-03-30 16:07 ` Marc Chantreux
2024-03-30 17:16   ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7ZFScinPmH9U-V0fjP1HdJJqSQJ4JHVFuwzT5NWiz=pFw@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).