moosh
moosh copied to clipboard
`top` fails on system without `tput` (e.g. bitnami docker image)
- moosh version: 1.1
- moodle version: 3.10.4
- database: MariaDB 5.7.34
- php version: 7.3.28
- operating system: Gnu/Linux.
uname -a
= Linux ... 5.4.109+ #1 SMP Tue Jun 8 19:56:04 PDT 2021 x86_64 GNU/Linux
Actual behaviour
If you run moosh top
an error is thrown from ToolsTop.php because tput
isn't available:
sh: 1: tput: not found
sh: 1: tput: not found
PHP Notice: Undefined offset: 0 in /usr/share/moosh/Moosh/Command/Generic/Tools/ToolsTop.php on line 28
Notice: Undefined offset: 0 in /usr/share/moosh/Moosh/Command/Generic/Tools/ToolsTop.php on line 28
PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 18890752 bytes) in /usr/share/moosh/includes/moodle/lib/dml/mysqli_native_moodle_database.php on line 1244
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 18890752 bytes) in /usr/share/moosh/includes/moodle/lib/dml/mysqli_native_moodle_database.php on line 1244
Expected behaviour
top
should work normally without an external dependency like tput
or at least fail gracefully without running an invalid command. It could catch errors on lines 26-27 of ToolsTop.php and default to some kind of safe/common set of parameters rather than dying. I'd image that, even though I haven't tested it, the reliance on tput
means the top command fails on Windows, too.
Steps to reproduce
- run the Bitnami Moodle image https://bitnami.com/stack/moodle
- install
moosh
on it - run
moosh top
on the image to reproduce the error
We're using Bitnami Moodle or I wouldn't have noticed, obviously on a full Ubuntu server you have tput
.