[152526] contrib/mp-buildbot/mpbb

larryv at macports.org larryv at macports.org
Sun Sep 11 18:58:58 PDT 2016


Revision: 152526
          https://trac.macports.org/changeset/152526
Author:   larryv at macports.org
Date:     2016-09-11 18:58:58 -0700 (Sun, 11 Sep 2016)
Log Message:
-----------
mpbb: Handle sourcing errors gracefully

There shouldn't actually be any runtime sourcing errors because the
sourced scripts just define functions, and function definitions only
fail due to what we would consider programming errors. But handle them
anyway.

Modified Paths:
--------------
    contrib/mp-buildbot/mpbb

Modified: contrib/mp-buildbot/mpbb
===================================================================
--- contrib/mp-buildbot/mpbb	2016-09-12 01:58:56 UTC (rev 152525)
+++ contrib/mp-buildbot/mpbb	2016-09-12 01:58:58 UTC (rev 152526)
@@ -155,16 +155,20 @@
 # enabled, "${foo[@]}" doesn't work if foo is empty.
 set -- ${args+"${args[@]}"}
 
-# Load the mpbb-$command scripts and source them to load the actual
-# implementations and help messages of available commands.
+# Load the subcommand implementations. Each sourced script "mpbb-FOO"
+# must define functions "FOO" and "FOO-help".
 cmds=()
 thisdir=$(cd "$(dirname "$0")" && pwd)
 for cmdfile in "$thisdir/mpbb-"*; do
     # Unfortunately ShellCheck does not currently support following multiple
     # files, so we'll just disable the warning.
     # shellcheck disable=SC1090
-    . "$cmdfile"
-    cmds+=("${cmdfile#$thisdir/mpbb-}")
+    if . "$cmdfile"; then
+        cmds+=("${cmdfile##*/mpbb-}")
+    else
+        err "failed to load subcommand script \`$cmdfile'"
+        exit 3
+    fi
 done
 
 if (( $# < 1 )); then
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20160911/21218e67/attachment.html>


More information about the macports-changes mailing list