From a08986066df1930d17b3509ff5b8d75edf8aafad Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Fri, 11 Jul 2014 20:21:20 -0700 Subject: [PATCH] add help on argument --- errallow-function | 9 +++++++-- errcatch-function | 15 +++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/errallow-function b/errallow-function index fb00d95..d44247b 100644 --- a/errallow-function +++ b/errallow-function @@ -13,5 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Undo the complimentary errcatch function -errallow() { set +eE +o pipefail; trap ERR; } +errallow() { + if [[ $1 ]]; then + echo "errallow help: Undo the complimentary errcatch function." + else + set +eE +o pipefail; trap ERR + fi +} diff --git a/errcatch-function b/errcatch-function index 92751bf..a46dfbc 100644 --- a/errcatch-function +++ b/errcatch-function @@ -13,11 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -# General purpose bash error handling setup -# Exit on all errors. Print useful information. -errcatch() { - set -eE; - trap 'echo "${BASH_COMMAND:+BASH_COMMAND=\"$BASH_COMMAND\" } +errcatch() { + if [[ $1 ]]; then + echo "errcatch help: Enable general purpose bash error handling. +Exit on all errors and print useful information." + else + set -eE; + trap 'echo "${BASH_COMMAND:+BASH_COMMAND=\"$BASH_COMMAND\" } ${FUNCNAME:+FUNCNAME=\"$FUNCNAME\" }${LINENO:+LINENO=\"$LINENO\" }\$?=$?"' ERR - set -o pipefail + set -o pipefail + fi } -- 2.25.1