From: Marlon Richert <marlon.richert@gmail.com>
To: "Lawrence Velázquez" <larryv@zsh.org>
Cc: Bart Schaefer <schaefer@brasslantern.com>,
Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [PATCH] Increase $COLUMNS when generating long option completions
Date: Wed, 4 Aug 2021 09:51:54 +0300 [thread overview]
Message-ID: <CAHLkEDsYUVFXEyzUG2m1O7PeXPM0J4VnscL-yM-fv2Kbj3h85A@mail.gmail.com> (raw)
In-Reply-To: <549459d9-eee8-43b2-b8c6-71c11291f012@www.fastmail.com>
On Wed, Aug 4, 2021 at 4:12 AM Lawrence Velázquez <larryv@zsh.org> wrote:
>
> On Tue, Aug 3, 2021, at 10:05 AM, Marlon Richert wrote:
> > On Mon, Aug 2, 2021 at 2:07 AM Bart Schaefer <schaefer@brasslantern.com> wrote:
> > >
> > > I'm puzzled, doesn't this imply that the value of $COLUMNS is
> > > incorrect on entry to the function?
> >
> > No, the problem results from _call_program being connected to a pipe:
> >
> > _call_program $lflag options ${~words[1]} --help 2>&1 |
> > while IFS= read -r opt; do
> >
> > When ${~words[1]} is an external command, it will then not see
> > $COLUMNS, unless $COLUMNS has been exported.
>
> Isn't that the case in general? External commands *never* see
> COLUMNS if it isn't in the environment. The pipe is a red herring.
>
> > For example, compare the output of the following:
> >
> > % pip3 --help
> > % _call_program tst pip3 --help
> > % _call_program tst pip3 --help | cat
> > % print -r -- "$( pip3 --help )"
>
> Seems like pip is behaving differently depending on whether it's
> outputting to a tty or not.
I feel that cannot be the whole story, because if I do any of the
following, I get terminal-width output, instead of 80 columns:
% COLUMNS=$COLUMNS pip3 --help | cat
% print -r -- "$( COLUMNS=$COLUMNS pip3 --help )"
% _call_program tst COLUMNS=$COLUMNS pip3 --help | cat
And pip isn't the only command that works that way. For example:
% ls -x /
Applications Library System Users Volumes bin cores dev etc home
opt private sbin tmp usr var
% ls -x / | cat
Applications Library System Users Volumes
bin cores dev etc home
opt private sbin tmp usr
var
% COLUMNS=$COLUMNS ls -x / | cat
Applications Library System Users Volumes bin cores dev etc home
opt private sbin tmp usr var
%
next prev parent reply other threads:[~2021-08-04 7:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-01 19:24 Marlon Richert
2021-08-01 23:06 ` Bart Schaefer
2021-08-03 14:05 ` Marlon Richert
2021-08-04 1:12 ` Lawrence Velázquez
2021-08-04 3:48 ` Bart Schaefer
2021-08-04 6:51 ` Marlon Richert [this message]
2021-08-04 7:19 ` Lawrence Velázquez
2021-08-05 6:19 ` Marlon Richert
2021-08-05 6:24 ` Bart Schaefer
2021-08-05 18:11 ` Marlon Richert
2021-08-05 23:44 ` Bart Schaefer
2021-08-07 19:55 ` Marlon Richert
2021-08-07 22:41 ` Bart Schaefer
2021-08-10 19:04 ` Marlon Richert
2021-08-10 19:17 ` Marlon Richert
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=CAHLkEDsYUVFXEyzUG2m1O7PeXPM0J4VnscL-yM-fv2Kbj3h85A@mail.gmail.com \
--to=marlon.richert@gmail.com \
--cc=larryv@zsh.org \
--cc=schaefer@brasslantern.com \
--cc=zsh-workers@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).