新风花雪月 发表于 2018-8-25 06:27:48

更多 shell 脚本技术

#!/usr/bin/bash  #########################################################################
  # traps
  #########################################################################
  # trap when a user is attempting to leave the script
  trap 'exit_msg 1 0 "Signal Caught. Exiting..."' HUP INT QUIT KILL ABRT
  trap 'window_size_changed' WINCH                # trap when a user has resized the window
  #########################################################################
  #########################################################################
  # defined/exported variables
  #########################################################################
  _MSG_SLEEP_TIME=3               # seconds to sleep for all messages
  # (if not defined, default will is 1 second)
  _CUSTNUM_SIZE=6                   # length of a customer number in this location
  # (if not defined, default is 6)
  _DEBUG_LEVEL=0                      # log debug messages. log level is accumulative
  # (i.e. 1 = 1, 2 = 1 & 2, 3 = 1, 2, & 3)
  # (if not defined, default is 0)
  # Log levels:
  #0 = No messages
  #1 = brief messages (start script, errors, etc)
  #2 = environment setup (set / env)
  #3 = set -x (A LOT of spam)
  _TMPDIR="/tmp"          # directory to put work/tmp files
  # (if not defined, default is /tmp)
  _SP_LOG="${0##*/}.log"   # log of script events
  _SP_REQUESTS="${HOME}/sp_requests"
  # file to customer record requests,
  # also read at startup
  _MENU_ITEMS=15      # default number of items to display per page
  # (it not defined, default is 10)
  LESS="-P LINE\: %l"      # format 'less' prompt. MAN less if more info
  # export the variables defined above
  export _MSG_SLEEP_TIME _CUSTNUM_SIZE _DEBUG_LEVEL _TMPDIR
  _SP_LOG _SP_REQUESTS _MENU_ITEMS
  #########################################################################

页: [1]
查看完整版本: 更多 shell 脚本技术