Search code examples
phpphing

Phing console width: override, or retrieve actual width value


I'm working on a cli php script that needs to be aware of the current console width (does periodic checks to `tput col`, outputs data in columns, linebreaks etc.).

This works fine when calling the script directly, but when running the script from a phing target, the width value is returned as '80' regardless of the actual console width, whether larger or smaller.

Is there a way to either determine the 'real' console width, or to override phing's default of 80 to something larger?


Solution

  • It turns out this is due to tput cols changing its behavior when standard out and standard error have been redirected.

    Alternative solution was to use `stty size` instead.