Window::getSize() => tput: unknown terminfo capability 'cols\nlines'
SebastienElet opened this issue · 7 comments
Hello,
I have the error :
tput: unknown terminfo capability 'cols\nlines'
Here is the code to reproduce the error :
<?php
require 'vendor/autoload.php';
var_dump(Hoa\Console\Window::getSize());
I use the package php5-cli on debian 7.5. The PHP Version => 5.4.4-14+deb7u9
I use a local tmux -> ssh -> zsh 4.3.17
The fallowing command is working :
$ echo "cols\nlines" | tput -S
272
91
Hello :-),
Can you print the $_SERVER
variable in a PHP script running in CLI please? I would like to know if the TERM
variable is available. Also, is PHP running with a specific user that has a shell?
When you say that echo "cols\nlines" | tput -S
is working, is it inside a tmux instance?
var_dump of $_SERVER
:
array(29) {
["LANG"]=>
string(11) "fr_FR.UTF-8"
["USER"]=>
string(4) "root"
["LOGNAME"]=>
string(4) "root"
["HOME"]=>
string(5) "/root"
["PATH"]=>
string(155) "/usr/local/freeswitch/bin:/usr/local/bin:/usr/local/sbin:/usr/local/share/npm/bin:/usr/local/sbin:/usr/local/bin:/usr/sb
in:/usr/bin:/sbin:/bin:/usr/bin/X11"
["MAIL"]=>
string(14) "/var/mail/root"
["SHELL"]=>
string(8) "/bin/zsh"
["SSH_CLIENT"]=>
string(23) "XX.XX.XX.XX 55551 22"
["SSH_CONNECTION"]=>
string(37) "XX.XX.XX.XX 55551 XX.XX.XX.XX 22"
["SSH_TTY"]=>
string(10) "/dev/pts/3"
["TERM"]=>
string(15) "screen-256color"
["LANGUAGE"]=>
string(8) "fr_FR:fr"
["SHLVL"]=>
string(1) "1"
["PWD"]=>
string(10) "/root/test"
["OLDPWD"]=>
string(5) "/root"
["HISTSIZE"]=>
string(4) "4096"
["HISTFILE"]=>
string(17) "/root/.zsh_istory"
["PROMPT"]=>
string(78) "%(?.%{%}✔.%{%}✖) %{%}%{%} %20<… <%/%<< %{%}❯ "
["RPROMPT"]=>
string(26) "%{%}%n@%m%{%}"
["_"]=>
string(12) "/usr/bin/php"
["PHP_SELF"]=>
string(8) "test.php"
["SCRIPT_NAME"]=>
string(8) "test.php"
["SCRIPT_FILENAME"]=>
string(8) "test.php"
["PATH_TRANSLATED"]=>
string(8) "test.php"
["DOCUMENT_ROOT"]=>
string(0) ""
["REQUEST_TIME_FLOAT"]=>
float(1401038003.974)
["REQUEST_TIME"]=>
int(1401038003)
["argv"]=>
array(1) {
[0]=>
string(8) "test.php"
}
["argc"]=>
int(1)
}
echo "cols\nlines" | tput -S
is working with or without tmux.
What about executing:
<?php
var_dump(shell_exec('echo "cols\nlines" | tput -S'));
(without Hoa actually)
If it fails, it is an issue related to PHP. What the user of PHP? Has this user a shell?
Edit: it seems that your run the script in root. Is it normal?
I am summarizing the yesterday IRC discussion. The command works in a regular shell, including as a root. The command does not work in PHP. This is not related to Hoa but to PHP. However, it would be great to detect the issue and prevent the user.
@nasga: Are you agree with my summary?
I have the same issue with the var_dump.
I'm able to reproduce the issue from cli.
$ sh --version
# GNU bash, version 4.2.37(1)-release (x86_64-pc-linux-gnu)
$ sh
$ echo "cols\nlines" | tput -S
# tput: unknown terminfo capability 'cols\nlines'
This issue seems to be related to my term.
echo -e
is working in php/cli.