#--------------------------------------
# 
# ***** DO NOT EDIT THIS FILE ****
# ***** DO NOT EDIT THIS FILE ****
#
# This file may be replaced in subsequent releases of Interix
# To avoid any problems, do not edit this file.
#
# Make any local system changes in /etc/profile.lcl
# which gets included at the end of this file
#
#
#--------------------------------------
#
#C+
# Copyright 1996 by Softway Systems, Inc.  All rights reserved.
# 
# This software source is the property of Softway Systems, Inc.
# Use is authorised only under the terms and  conditions set out in the 
# product code licence agreement protecting this Software Source.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' BY SOFTWAY SYSTEMS, INC. AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL SOFTWAY SYSTEMS, INC. BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#C-

#----------------------------------------------
# RCSID = $Header: //P/src/etc.files/RCS/profile 1.30 1998/05/12 18:03:18 SSI_DEV+mark Exp $
#
# Filename: /etc/profile
# 
# Welcome to the Interix Commands and Utilities.
#
# This is the system level shell profile that is sourced in when a shell 
# starts.  This is where system level environment configuration should take 
# place, and it should be done by the system's administrator.
#
# Please remember to ensure that this file has no carriage-return/line-feeds
# after editing it. If you do use a Win32 program to edit this file,
# be sure to run /Interix/bin/flip to convert it back into the 
# UNIX/POSIX format.
#
#  e.g) From a CMD.EXE command prompt
#
#    $ c:\Interix\bin\flip -u profile
#
# The file //C/Interix/etc/profile.usr is an example user profile.
# You may copy it into the home directory of each user of the Interix
# commands and utilities, and rename it to .profile in the user's home
# directory. The user can then edit it to his or her own preferences.

umask 022

# -------------
# PATH setup:

# save the original 'PATH'  environment variable to PATH_ORIG
# so the user can use it in his/her personal profile later.
#
PATH_ORIG=$PATH

# 
#  When a POSIX subsystem process is started, the PATH environment 
#  variable is created from the system NT 'Path' variable by changing 
#  the directory separator from ";" to ":", and the drive letter ids
#  from "N:" to "//N".
#
#  We now prefix it with the path to where the Interix commands
#  and utilities product was installed.
#
#
# NOTE: OPENNT_ROOT env. variable was initialized when the product
#       was installed. But just in case someone nuked it, we use a default
#
OPENNT_ROOT=${OPENNT_ROOT:-//C/Interix/}   # use a default, if necessary
# remove trailing '/' if any 
__x_installdir=${OPENNT_ROOT%/}
__X11=usr/X11R5

export PATH="$QTREE/bin:${__x_installdir}/bin:${__x_installdir}/usr/contrib:${__x_installdir}/usr/contrib/bin:${__x_installdir}/${__X11}/bin"

#
# now check for the existence of a directory to the local compiler 
#
if [ "$OPENNT_COMPILERDIR" != "" ]; then
    #
    # VC/BIN and SharedIDE/BIN are necessary for MSVC5.0 support
    # because both there directories contain required DLLs
    #
    for _i in BIN VC/BIN SharedIDE/BIN; do
	_i="$(ntpath2posix -c ${OPENNT_COMPILERDIR}/${_i})"
	if [ -d "${_i}" ]; then
	    export PATH="$PATH:${_i}"
	fi
    done
    unset _i
fi

# -------------
#
# TMPDIR is used by a number of utilities as a place in which temporary files
# can always be placed.
#
# Look for several 'tmp' environment variables and check if any of these
# directories exist.
# If so, then use this directory as the value for TMPDIR
# Order of precedence:
#    OPENNT_TMPDIR 
#    TMPDIR	// user can set this in "ControlPanel/System/Environment"
#    TMP	// this is usually initialized already by NT
#    TEMP	// this is usually initialized already by NT
#
# Note: OPENNT_TMPDIR and TMPDIR are available so that user can set these
#       via the "ControlPanel/System/Environment".
#
origTMPDIR=${TMPDIR}	 # save original value
unset TMPDIR		# unset TMPDIR so we can tell below if TMPDIR was set

for _i in ${OPENNT_TMPDIR} ${origTMPDIR} ${TMP} ${TEMP}; do

   # try path in POSIX format and using existing case
   _x=$(ntpath2posix ${_i})
   if [ -d "${_x}" ]; then
   	export TMPDIR=${_x}
	break
   fi
   # try path in POSIX format and all uppercase
   _x=$(ntpath2posix -u ${_i})
   if [ -d "${_x}" ]; then
   	export TMPDIR=${_x}
	break
   fi
   # try path in POSIX format and all lowercase
   _x=$(ntpath2posix -l ${_i})
   if [ -d "${_x}" ]; then
   	export TMPDIR=${_x}
	break
   fi
done
unset origTMPDIR
unset _i
unset _x
#
# If TMPDIR still not set, then use the default value of "/Interix/tmp"
# which was created at install time
# NOTE: permissions on this directory may need to be changed to 777
#       because this is not done at install time.
#
export TMPDIR=${TMPDIR:-${__x_installdir}/tmp}

# *** NOTE:
#    we do NOT convert TMP or TEMP (if they exist) to POSIX format
#    because user may invoke a Win32 program which uses this value
#    and if so, it must be in the Win32 format

# -------------
#
# Terminal Behaviour
# The terminal behaves properly with respect to newlines, (versus carriage-
# return/newline) and cursor control for utilities like more and vi, if
# the following variables are correctly configured.  TERM should be set to
# opennt, TERMCAP needs to point to the directory with the termcap file.
#

export TERM=${TERM:-opennt}
export TERMCAP="${TERMCAP:-${__x_installdir}/usr/share/termcap}"

#
# Set up the default MANPATH
#
if [ "$MANPATH" = "" ]; then
    export MANPATH="$QTREE/man:${__x_installdir}/usr/share/man:${__x_installdir}/${__X11}/man"
fi


# Set up X11 variables
#
export XAPPLRESDIR=${XAPPLRESDIR:-\
${__x_installdir}/${__X11}/lib/X11/app-defaults}

export XFILESEARCHPATH=${XFILESEARCHPATH:-\
${XAPPLRESDIR}/%N%S:${__x_installdir}/${__X11}/include/X11/bitmaps/%N%S}

export XKEYSYMDB=${XKEYSYMDB:-${__x_installdir}/${__X11}/lib/X11/XKeysymDB}
export XCMSDB=${XCMSDB:-${__x_installdir}/${__X11}/lib/X11/Xcms.txt}
export UIDPATH=${__x_installdir}/${__X11}/lib/X11/uid/%U
export XNLSPATH=${__x_installdir}/${__X11}/lib/X11/nls

#
# try to inherit DISPLAY from environment. If not, then make sure its set
#
if [ "$DISPLAY" = "" ]; then
	export DISPLAY="localhost:0.0"
fi

# -------------
#
# These environment variables are used by various utilities to invoke 
# an editor.  Set to vi initially.  The last is for utilities.
#
export EDITOR=elvis
export VISUAL=elvis
export FCEDIT=elvis

# user must explicitly set SHELL - we don't want to inherit a bogus one
# from the NT/Win32 environment because it will probably be in the 
# incorrect path syntax and it may point to the wrong shell
#
unset SHELL		

# -------------
#
# Change directory to user's home directory.
# On UNIX, this would be done by the login(1) program, but since
# we don't always run login(1) (for example, from a shortcut) we emulate
# it here to be sure.
#
if [ "$HOME" != "" ]; then
    cd $HOME
fi

# -------------
# now read in the system local profile
#
if [ -f ${__x_installdir}/etc/profile.lcl ]; then
    . ${__x_installdir}/etc/profile.lcl
fi

# -------------
# now unset the local variables
#
unset __x_installdir
unset __X11
