Setting bash as the default shell with grendel and hermite

D. Thiébaut


This document describes a fairly crude but workable way to use bash under both SunOS on grendel and the Sparcstations, as well as under IRIX on the SGI computers.

The end of this document shows how to create executable programs that can be run transparently of the operating system used.

  1. Set bash as your default shell:
    		% chsh
    		Old shell: xxxxxxxxxxxxxxx
    		New shell: /local/bin/bash
    	
  2. Create two .environment files: .environment.IRIX and .environment.SunOS

    Here are skeleton versions of both

  3. create a .bashrc file that will detect which OS it is running under, and will execute appropriate commands, and load either .environment.IRIX or .environment.SunOS.

    	# find out what OS we're running under
    	OS=`uname -s`
    
    	if [ `echo $OS | grep "IRIX"` ];  then
    	    OS="IRIX"
    	fi
    	export OS
    
    	# Load our environment (specific to the given OS)
    	if [ -f $HOME/.environment.$OS ]; then
    	    source $HOME/.environment.$OS
    	fi
    
    	#--- load SunOS stuff now ---------------------------------------------
    	if [ $OS = "SunOS" ]; then
    	
    		export OPENWINHOME=/usr/openwin
    		export MINICOM="-c on"
    
    		PATH="$PATH:/usr/X11/bin:/usr/andrew/bin:$OPENWINHOME/bin:/usr/games:."
    		LESS=-MM
    		eval tset
    
    		PS1='[\h]\n[\t] \w\$: '
    		PS2='> '
    		if [ ! "$SHELL" = "/bin/ash" ]; then # ash doesn't have aliases
    	 	 alias net='term < /dev/modem > /dev/modem 2> /dev/null&'
    		fi
    
    		alias dir=ls
    		alias h=history
    		alias a=alias
    		ignoreeof=10
    		export PATH DISPLAY LESS TERM PS1 PS2 ignoreeof
    		umask 066
    		biff y
    		HISTSIZE=32
    		MAILCHECK=60
    	fi
    
    	#--- load IRIX stuff now ---------------------------------------------
    	if [ "$OS" = "IRIX" ]; then
    
    		PATH="/usr/local/bin:/usr/freeware/bin:/sbin:/usr/bin:/usr/bin/X11:/usr/bsd:/usr/etc:/usr/sbin:/usr/java/bin:.:$HOME/bin"
    	
    		LESS=-MM
    		eval tset
    
    		PS1='[\h]\n[\t] \w\$: '
    		PS2='> '
    		if [ ! "$SHELL" = "/bin/ash" ]; then # ash doesn't have aliases
    		 alias net='term < /dev/modem > /dev/modem 2> /dev/null&'
    		fi
    
    		alias dir=ls
    		alias h=history
    		alias a=alias
    		ignoreeof=10
    		export PATH DISPLAY LESS TERM PS1 PS2 ignoreeof
    		umask 066
    		HISTSIZE=32
    		MAILCHECK=60
    
    	fi
    
    
    	#---- Stuff common to IRIX and SunOS ---------------------------------
    	# (put here commands that work under both Operating Systems.
    	
  4. A related issue: if you want to run executables in your bin directory independently of the OS you use, follow the approach outlined below:

    Assume that you have a program called hello.c and want a working copy for both machines. Compile it on grendel and call the executable hello.SunOS, and the one for hermite hello.IRIX. Then create a shell file called hello that will test which OS it is running under and will select the appropriate executable. With bash it looks like this:

    	#! /local/bin/bash
    	OS=`uname -s`
            if [ `echo $OS | grep "IRIX"` ];  then
                OS="IRIX"
            fi
            hello.$OS $@
    	

    That works pretty well! Note: if you have exported the variable $OS in your .bashrc file, then $OS will be part of your environment, and you can skip Lines 2 to 5 of the shell file above:

    	#! /local/bin/bash
    	hello.$OS $@
    	

Back to FAQ     Home Page