cli-menu icon indicating copy to clipboard operation
cli-menu copied to clipboard

Check if tput exists before casting the exec result to an int

Open gezzyramos opened this issue 6 years ago • 6 comments

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 terminal

with change

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

gezzyramos avatar Mar 11 '19 15:03 gezzyramos

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!

AydinHassan avatar Mar 11 '19 17:03 AydinHassan

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

gezzyramos avatar Mar 11 '19 18:03 gezzyramos

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

AydinHassan avatar Mar 11 '19 19:03 AydinHassan

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.

gezzyramos avatar Mar 11 '19 19:03 gezzyramos

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.

AydinHassan avatar Mar 12 '19 04:03 AydinHassan

Of course, it would be good to inform when the system has not tput :)

gezzyramos avatar Mar 12 '19 13:03 gezzyramos