Re: [opensuse] BASH: has $COLUMNS gone nuts?



On Thursday July 23 2009, David C. Rankin wrote:
On Thursday 23 July 2009 10:13:00 pm Randall R Schulz wrote:
...

Randall,

I kind of follow you here. Are you saying that I need to do both
queries in each script to determine if the proper environment or
variable parameters? What I was getting at is that I have used LINES
& COLUMNS in scripts in the past that relied on both but didn't have
to alter the environment. Why are these needed now?

I only meant to give you a data point per your request. The vq and eq
procedures are generic and I use them quite a lot, though not that I
can recall for COLUMNS.

You can always just put an export command in your .bash_profile
or .login file (I can never keep straight which you use for what
but .bashrc will always work, of course, even though it's highly
redundant to do so for environment variables).

Anyway, I don't know if COLUMNS is updated when the terminal size is
changed. I do know that the stty output is always current. I have
another script for that, "tsize":

-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
#!/bin/bash --norc

rowsOnly=
colsOnly=

for arg; do

case "$arg" in

-r | --row | --rows)
rowsOnly=1
colsOnly=
;;

-c | --col | --cols)
colsOnly=1
rowsOnly=
;;

esac

done


stty -a \
|(
if [ $rowsOnly ]; then
sed -rn '/rows/ s/.*rows +([^;]+);.*/\1/p'
elif [ $colsOnly ]; then
sed -rn '/columns/ s/.*columns +([^;]+);.*/\1/p'
else
sed -rn '/rows.*columns/ s/.*(rows[^;]+;[^;]+);.*/\1/p'
fi
)
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-

% tsize
rows 97; columns 180


It can easily be modified to output a COLUMNS (or ROWS) -setting
command, of course.


--
David C. Rankin


Randall Schulz
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx



Relevant Pages