Closed vgarvardt closed 6 years ago
Agreed, many folks (including us) are using Docker with Alpine images. stty is the go IMO
@vgarvardt I use this writer with docker, but all of our images are based on ubuntu:latest
or ubuntu16.04
so it didnt dawn on me to try it with alpine
I will test this against both ubuntu:latest
and ubuntu:16.04
and if all is fine there as well, I will get it merged and be part of the next release.
Thanks for the PR :-)
Can I suggest the following change @vgarvardt - it wasn't working for me in CI (CircleCI with default debian php:$version
images).
It also defaults to 120 width when non interactive:
private function getWidth()
{
exec('stty size 2>/dev/null', $out, $exit);
if ($exit !== 0) {
return '120';
}
// 'stty size' output example: 36 120
return (int) explode(' ', array_pop($out))[1];
}
The stderr redirect is needed because in debian when non-tty some warning output would be displayed.
I tested it with the following commands:
# interactive
docker run -v $(pwd):/app -w /app --rm -it php:7.2 vendor/bin/phpunit
docker run -v $(pwd):/app -w /app --rm -it php:7.2-alpine vendor/bin/phpunit
# non-interactive
docker run -v $(pwd):/app -w /app --rm php:7.2 vendor/bin/phpunit
docker run -v $(pwd):/app -w /app --rm php:7.2-alpine vendor/bin/phpunit
tput
is not available in some systems, like Alpine that is widely used in CI tasks.stty
is more widely available and is part of coreutils.