Skip to content

Commit 7c0e443

Browse files
committed
add logging and error handling helper functions
1 parent dfc6c70 commit 7c0e443

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tools/build_test_env.sh

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
# You should have received a copy of the GNU Lesser General Public License
1515
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17+
pecho() { printf %s\\n "$*"; }
18+
log() {
19+
[ "$#" -eq 0 ] || { pecho "$@"; return 0; }
20+
while IFS= read -r log_line || [ -n "${log_line}" ]; do
21+
log "${log_line}"
22+
done
23+
}
24+
error() { log "ERROR: $@" >&2; }
25+
fatal() { error "$@"; exit 1; }
26+
try() { "$@" || fatal "'$@' failed"; }
27+
1728
PY_VER=2
1829
while getopts :p: opt "$@"; do
1930
case $opt in

0 commit comments

Comments
 (0)