refcodes-batch.1.0.2.source-code.lib-common.inc Maven / Gradle / Ivy
#!/bin/bash
# ------------------------------------------------------------------------------
# Common functions for shell scripts.
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Exit codes:
# ------------------------------------------------------------------------------
EXIT_SUCCESS=0
EXIT_FAILURE=1
EXIT_ERROR=2
EXIT_BUG=10
EXIT_OFF=99
# ------------------------------------------------------------------------------
# Boolean values:
# ------------------------------------------------------------------------------
OFF=0
FALSE=0
NO=0
ON=1
TRUE=1
YES=1
# ------------------------------------------------------------------------------
# function: include ""
# ------------------------------------------------------------------------------
# function include {
# local INCLUDE_FILE="$1"
# if [[ ! $# -eq 1 ]] ; then
# log "${LOG_ERROR}" "Number of parameters passed to function \"include\" mismatch (exactly one parameter expected)! Passed args were \"$@\"."
# return ${EXIT_ERROR}
# fi
# log "DEBUG" "Checking file: $INCLUDE_FILE"
# if [[ -e ${INCLUDE_FILE} ]] ; then
# log "DEBUG" "Reading file: ${INCLUDE_FILE}"
# source ${INCLUDE_FILE}
# if [[ "$?" -ne "0" ]] ; then
# log "${LOG_ERROR}" "Sorry, cannot include file: $INCLUDE_FILE"
# return $EXIT_FAILURE
# fi
# log "DEBUG" "Done reading file: $INCLUDE_FILE"
# else
# log "${LOG_ERROR}" "File not found: $INCLUDE_FILE"
# return $EXIT_FAILURE
# fi
# log "Leaving function include..."
# }