I've been trying to figure out how to make this simple shell script work: #!/bin/bash echo $COLUMNS apperantly, the way to do this is to say COLUMNS=$COLUMNS cow.sh or export $COLUMNS cow.sh but the other way is it have these imporant enviorment variables exported by default Reproducible: Didn't try Steps to Reproduce: 1. 2. 3.
i dont have COLUMNS defined anywhere in my files yet that var works when i start a new bash what shell do you use ?
bash-2.05b$ whoami aaron bash-2.05b$ bash --version GNU bash, version 2.05b.0(1)-release (i686-pc-linux-gnu) Copyright (C) 2002 Free Software Foundation, Inc. bash-2.05b$ cat cow2.sh #!/bin/bash #shopt -s checkwinsize #kill -n 28 $$ echo $COLUMNS bash-2.05b$ ./cow2.sh bash-2.05b$ . cow2.sh 71 bash-2.05b$ COLUMNS=$COLUMNS ./cow2.sh 71 bash-2.05b$
from bash(1): COLUMNS Used by the select builtin command to determine the terminal width when printing selection lists. Automatically set upon receipt of a SIGWINCH. from signals(7): SIGWINCH 28,28,20 Ign Window resize signal (4.3 BSD, Sun) if you want access to that kind of information in scripts i'd suggest you utilize `stty size`