# SccsId[] = "%W% (USL function) %G%"
              DPL_name="DEBUG_PAUSE_LOOP"
              if [ ".${SECONDS}" = "." ]; then # Bourne function already loaded?
                 [ ."`set|egrep '^$DPL_name\(\)\{$'`" != . ] && DPL_loaded=1
              else # Korn or Bash shell and function already loaded?
                 if [ `expr "\`uname -s\`" : "[Ll][Ii][Nn][Uu][Xx]"` -eq 0 ]; then
                    [ ."`typeset +f|awk '/^'$DPL_name'[=\(]?/'`" != . ] && DPL_loaded=1
                 else # Linux
                    [ ."`typeset -F|awk '/^'$DPL_name'[=\(]?/'`" != . ] && DPL_loaded=1
                 fi
              fi
              if [ 0${DPL_loaded} -eq 0 ]; then
              #----------------------------------------------------------------------#
              DEBUG_PAUSE_LOOP() # Function documentation located at bottom.         #
              #----------------------------------------------------------------------#
              {
                #-----------------------------------------------------------------#
                # If running interactively, prompt user for a command and process #
                # it.  Else return with failure status.                           #
                #-----------------------------------------------------------------#
                if [ .$TERM != . ]; then
                   DPL_pause="." # Just to give it something.
                   while [ ".$DPL_pause" != "." ]
                   do
                      /bin/echo "Enter command | press ENTER to QUIT debug: \c"
                      read DPL_pause
                      #--------------------------------------------------------#
                      # If -e (eval) flag was passed when we were called, then #
                      # evaluate the user's command, else, just execute it.    #
                      #--------------------------------------------------------#
                      [ .${1} = ."-e" ] && eval $DPL_pause || $DPL_pause
                   done
                   echo "Quitting debug."
                   return 0 # Success
                else
                   return 1 # failure
                fi
              } # "DPL_" prefix identifies this function's variables.
              fi

              #======================================================================#
              #                       D O C U M E N T A T I O N                      #
              #======================================================================#
              #                                                                      #
              #      Author: Bob Orlando                                             #
              #                                                                      #
              #        Date: November 13, 1997                                       #
              #                                                                      #
              #  Program ID: debug_pause_loop.sh                                     #
              #                                                                      #
              #       Usage: DEBUG_PAUSE_LOOP [-e]                                   #
              #                          where -e signals 'eval' operation is to be  #
              #                                   performed on the commands entered. #
              #                                                                      #
              #     Purpose: Provide a loop for debugging that executes commands     #
              #              passed to it.  The function terminates when no command  #
              #              is received (the ENTER key pressed with nothing on the  #
              #              command-line).                                          #
              #                                                                      #
              #     Globals: No global variables assigned from this function.        #
              #             "DPL_" prefix identifies local function variables.       #
              #                                                                      #
              # Exit_status: Nothing (debug function).                               #
              #                                                                      #
              #       Calls: Nothing (debug function).                               #
              #                                                                      #
              #       Notes: This function operates ONLY when the calling script     #
              #              is run interactively.  Run via batch or cron, and the   #
              #              function does nothing, returning failure status (1).    #
              #                                                                      #
              #    Modified: 2004-03-03 Bob Orlando                                  #
              #                 v1.6  * Change set|egrep|awk to just set|egrep.      #
              #                                                                      #
              #----------------------------------------------------------------------#
            
Artificial Intelligence is no match for natural stupidity.
©Copyright Bob Orlando, 1997-2011
All rights reserved.
http://www.OrlandoKuntao.com
E-mail: Bob@OrlandoKuntao.com
Last update: Jan. 26, 2011
by Bob Orlando