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

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



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.

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 )"

The first two will produce output that is as wide as the terminal,
whereas the latter two will always produce 80 columns of output.




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