Collin Funk wrote: > Section 8.3 "Other Environment Variables" has a decent description [1]. > The newest draft is better since it mentions tcgetwinsize & tcsetwinsize. > > The process goes something like: > > 1. If $LINES and $COLUMNS are set to positive decimal numbers use them. > - POSIX recommends users leave these unset unless there is a reason > to override system behavior (e.g. output narrower than the actual > window).
Here's the first thinko. Many programs (ps, pstree, man/groff) are supposed to write their output through a pager program, e.g. 'less'. Which means that the program does not write to a terminal; it writes to a pipe. If COLUMNS is unset in this situation, the POSIX recommentation will not match user expectations: * Through $TERM and the terminal description, resized terminal windows in a GUI don't work: $ infocmp -L xterm | grep columns columns#80, init_tabs#8, lines#24, max_colors#8, * tcgetwinsize does not work either, since it works only on ttys, not on pipes. The result would be that when a pager program is used, column widths are nearly always wrong. > ... > I think bash updates $LINES and $COLUMNS after every command by default, > but I'm not sure how other shells behave. It would be useful to test this with a few more shells, to see whether it can be relied upon. Bruno