#!/bin/sh
##################################################################################
## Bashish, a console theme engine
## Copyright (C) 2005-2006 Thomas Eriksson
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
## 
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
##################################################################################

## Cygwin needs to be put into OEM mode for spiffy ASCII graphics
test "x$TERM" = xcygwin && case "$CYGWIN" in
*codepage:oem*) unset CYGWIN ; test "x$OLD_CYGWIN" != x && CYGWIN=$OLD_CYGWIN;unset OLD_CYGWIN;;
*) OLD_CYGWIN="$CYGWIN";export OLD_CYGWIN;CYGWIN="$CYGWIN codepage:oem" exec "${0#-*}";;
"") CYGWIN=codepage:oem exec "${0#-*}" ;;
esac

## Cygwin (and others?) does not set COLUMNS and LINES by default
## in CygPuTTY COLUMNS and LINES get set to 0,0
if test "x$LINES$COLUMNS" = x -o "x$LINES$COLUMNS" = x00
then
	COLUMNS=$(stty size)
	LINES=${COLUMNS% *}
	COLUMNS=${COLUMNS#* }

	export COLUMNS LINES
fi

## cygwin reports errornous size
test "x$TERM" = xcygwin && {
	COLUMNS=`expr $COLUMNS - 1`
}
