#!/bin/sh -u # $0 [ arg1 [ arg2 [arg3] ] ] # With no arguments, display: PWD PATH HOME # With 1 argument, display: arg1 PATH HOME # With 2 arguments, display: arg1 arg2 HOME # With 3 arguments, display: arg1 arg2 arg3 # -IAN! idallen@ncf.ca # Save the user's path before modifying it for use in this script. # savepath="$PATH" export PATH=/bin:/usr/bin umask 022 if [ $# -gt 3 ] ; then echo 1>&2 "$0: Expecting 0-3 args; found $# ($*)" exit 1 fi # Set the initial values of the three variables. # Use the saved version of $PATH from above. # arg1="$PWD" arg2="$savepath" arg3="$HOME" # Change the variables depending on the number of arguments. # if [ $# -ge 1 ] ; then arg1="$1" fi if [ $# -ge 2 ] ; then arg2="$2" fi if [ $# -ge 3 ] ; then arg3="$3" fi echo "$arg1 $arg2 $arg3"