zsh-users
 help / color / mirror / code / Atom feed
* stty size doesn't work
@ 2022-10-23 20:47 Ray Andrews
  2022-10-23 22:21 ` Roman Perepelitsa
  0 siblings, 1 reply; 3+ messages in thread
From: Ray Andrews @ 2022-10-23 20:47 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 616 bytes --]

I doubt this is zsh's problem but she may have a solution just the 
same.  I do this in my 'i' function:

     width=${=$( stty size )[2]}

... and it works fine, however if I call the function thusly:

    _function_test ()
    {
         local integer i=0
         while read aa; do
             let i++
             eval ${=aa} 2> /dev/null
         done
    }

     $ _function_test <<< "i path"

... 'width' is zero.  I think this is some 'stty' issue, still the 
function will be running in a terminal and the terminal has a width so 
it puzzles me that no width can be reported.


[-- Attachment #2: Type: text/html, Size: 956 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: stty size doesn't work
  2022-10-23 20:47 stty size doesn't work Ray Andrews
@ 2022-10-23 22:21 ` Roman Perepelitsa
  2022-10-24  2:59   ` Ray Andrews
  0 siblings, 1 reply; 3+ messages in thread
From: Roman Perepelitsa @ 2022-10-23 22:21 UTC (permalink / raw)
  To: Ray Andrews; +Cc: Zsh Users

On Sun, Oct 23, 2022 at 10:47 PM Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> I doubt this is zsh's problem but she may have a solution just the same.  I do this in my 'i' function:
>
>     width=${=$( stty size )[2]}
>
> ... and it works fine, however if I call the function thusly:
>
> _function_test ()
> {
>     local integer i=0
>     while read aa; do
>         let i++
>         eval ${=aa} 2> /dev/null
>     done
> }
>
>     $ _function_test <<< "i path"
>
> ... 'width' is zero.

`stty size` needs the TTY as stdin. When you are invoking it from
_function_test, stdin is not a TTY. Use $COLUMNS instead. There is
also $LINES if you need height.

    width=$COLUMNS

Roman.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: stty size doesn't work
  2022-10-23 22:21 ` Roman Perepelitsa
@ 2022-10-24  2:59   ` Ray Andrews
  0 siblings, 0 replies; 3+ messages in thread
From: Ray Andrews @ 2022-10-24  2:59 UTC (permalink / raw)
  To: zsh-users


On 2022-10-23 15:21, Roman Perepelitsa wrote:
> width=$COLUMNS 

It's that simple! Thanks.



> Roman.
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-24  3:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-23 20:47 stty size doesn't work Ray Andrews
2022-10-23 22:21 ` Roman Perepelitsa
2022-10-24  2:59   ` Ray Andrews

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