Check if tput exists before casting the exec result to an int
Hello, when calling the setWidth function it checks if the passed value is greater than the total width of the terminal, but in my case the maximum width of the terminal always returns zero, for some reason the getWidth function can not get the actual width of the terminal .
I suggest setting a default maximum value, if the getWidth function returns zero.
Screenshots
without changing

with change
File: MenuStyle.php
line 390: $width = ($this->terminal->getWidth() != 0) ? $this->terminal->getWidth() : 75 ;

Hmm. Seems a bit hacky, we can certainly look at this but I'd rather figure out why getWidth() is returning 0. What does put cols return in your terminal? What terminal are you using? OS? Thanks!
Of course, the ideal would be to know why getWidth() is returning 0.
tput cols return 213
Deepin's terminal, edition 15.9.1 Desktop
Interesting. Could you try: php -r "var_dump(exec('tput cols'));" ?
And maybe also: php -r "var_dump(function_exists('exec'));"
I'm wondering if maybe exec is disabled in your environment
The problem is in my environment.
I have the application in docker and the system used does not have the tput command.
so the issue can be closed. :D
Thank you for your help.
Cool, glad we found it. Maybe we can add a better error message? Do you think it’s worth it?
Sent from my iPhone
On 11 Mar 2019, at 23:40, Gezzy Ramos <[email protected]mailto:[email protected]> wrote:
The problem is in my environment. I have the application in docker and the system used does not have the tput command.
so the issue can be closed. :D
Thank you for your help.
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/php-school/cli-menu/issues/169#issuecomment-471692160, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACr76hWqPpPAeBETVboPvQhSWuv7F4Eoks5vVrEtgaJpZM4bo024.
Of course, it would be good to inform when the system has not tput :)