Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Increase $COLUMNS when generating long option completions



On Tue, Aug 3, 2021, at 10:05 AM, Marlon Richert wrote:
> On Mon, Aug 2, 2021 at 2:07 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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.

-- 
vq




Messages sorted by: Reverse Date, Date, Thread, Author