[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Troublesome checkwinsize (none) behaviour

From: Linda Walsh
Subject: Re: Troublesome checkwinsize (none) behaviour
Date: Sat, 13 Jul 2013 02:52:07 -0700
User-agent: Thunderbird

address@hidden wrote:
        As subject says:
          * If checkwinsize is _not_ set the bash does not update the
            internal LINES and COLUMNS varaible during a command/job is
            running in foreground on same terminal.

          * If checkwinsize is set bash/libreadline does export LINES and
            COLUMNS breaking ncurses/TIOCGWINSZ based commands/jobs.

Bash doesn't export them:
I have checkwin on:

  shopt|grep checkwin
  checkwinsize    on

But neither ROWS nor COLUMNS are set in the env:
  printenv|grep -P 'ROWS|COL'
  declare -i w=COLUMNS/2;

Note -- "/etc/rc.status on Opensuse *does* export COLUMNS for all processes.
It also sets up it's own signal handler which re-exports them on any
window change:

  # Seek for terminal size and, if needed, set default size
  rc_lc () {
      if test -n "$REDIRECT" ; then
          set -- $(stty size < "$REDIRECT"  2> /dev/null || echo 0 0)
          set -- $(stty size 2> /dev/null || echo 0 0)
      test $LINES   -eq 0 && LINES=24
      test $COLUMNS -eq 0 && COLUMNS=80
      export LINES COLUMNS
  trap 'rc_lc' SIGWINCH

I ran into the above when writing scripts because COLS/LINES would often be
undefined, so I had to protect many of my start scripts:

  B4ops="${-//[^eu]/}" ; set +e +u        # turn off strict fails
  . /etc/rc.status                        #safely include rc.status
  [[ $B4ops ]] && set -$B4ops

It would seem any process launched by init would have at least
COLUMNS in it's environment unless the ENV had been explicitly cleared --
and I know for interactive sessions, it is not.

As I found startup functions that dirtied the namespace with names like:

  path ()
      command -p ${1+"$@"}
Not even putting an underscore in front or back of it.  'path' is a
not an uncommon name for shell scripts to use.

Also, I assume you know that suse scripts export COLUMNS in places
like  /etc/profile, /etc/csh.login and /etc/ksh.kshrc...

Perhaps one of those is propagating to the error cases mentioned?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]