#! /bin/ksh

#
# Name        : ${HOME}/bin/set-e.ksh
#
# Version     : 1.0
#
# Author      : Gerard van Wageningen
#
# Description : Use trap to exit script in case of errors
#
# 1.0   First Version
#

\whence set_debug 1>/dev/null 2>&1 && eval $( set_debug ${0##*/} )

error_handler()
{
  print -u2 "Script ended premature."
  print 'Script ended premature.' | mail -s 'Script ended premature' "${USER}"

  # Return instead of exit results in $? == 1 when this script stops.
  exit 3
}

trap "error_handler $?" ERR

# If a command has a non-zero exit status, execute the ERR trap,
# if set, and exit. This mode is disabled while reading profiles.
set -e 

\cd /etc/security

exit 2

###################### EOF ######################
