add help on argument
authorIan Kelling <ian@iankelling.org>
Sat, 12 Jul 2014 03:21:20 +0000 (20:21 -0700)
committerIan Kelling <ian@iankelling.org>
Fri, 12 Aug 2016 22:35:09 +0000 (15:35 -0700)
errallow-function
errcatch-function

index fb00d95e495dbb121d2f62fbfd479690066ec2d7..d44247bd96a18855f658bf3b5719098920898083 100644 (file)
 # 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
+}
index 92751bf99f49c84ae176eb8fba6eb3d9b5c419b8..a46dfbccf13b1f1e0beb571b88bf327345071702 100644 (file)
 # 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
 }