Walter Dnes <waltdnes@???> writes:
> ...at the commandline works, but the script
> #!/bin/bash
> echo ${LINES} ${COLUMNS}
> ...returns nothing.
It's a bit odd, but it's consistent with the behaviour described in the
man page. The man page for bash 5.3 says that if the checkwinsize option
is enabled (the default since bash 5.0), "bash checks the window size
after each external (non-builtin) command and, if necessary, updates the
values of LINES and COLUMNS".
The "after each external command" part is important - if I run:
#!/bin/bash
/bin/echo First $LINES $COLUMNS
/bin/echo Second $LINES $COLUMNS
(in an environment where LINES/COLUMNS are not exported, and using
/bin/echo to avoid the builtin echo) then I get:
First
Second 43 80
because no external command has been executed yet the first time. In an
interactive shell, LINES/COLUMNS are also set when job control is
initialised, but in a script it looks like you need to have run an
external command first. Your script works fine for me if I add a call to
/bin/true as the first line...
--
Adam Sampson <ats@???> <http://offog.org/>