Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
LU-1199 lbuild: Fix error handling
Improper grouping of expressions in the error() function meant
that even a simple "lbuild -h" would trigger a backtrace, and email to
someone at whamcloud.com.  That is fixed here.

Also stop sending email to a static email address on errors.

Also fix a minor typo.

Change-Id: I5a3f6131baaadc9dba23414e9e959f72fbda2679
Signed-off-by: Christopher J. Morrone <morrone2@llnl.gov>
  • Loading branch information
morrone committed Feb 27, 2013
1 parent 0e7500d commit dcce9cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
7 changes: 3 additions & 4 deletions contrib/lbuild/funcs.sh
Expand Up @@ -6,16 +6,15 @@ cleanup() {
error() {
local msg="$1"

[ -n "$msg" ] && echo -e "\n${0##*/}: $msg" >&$STDOUT

if [ -n "$msg" ]; then
echo -e "\n${0##*/}: $msg" >&$STDOUT
fi
}

fatal() {

This comment has been minimized.

Copy link
@brkorb

brkorb Mar 2, 2013

The real bug is right here. A fatal error (or non-error exit) has been detected. Thus it is caught, not uncaught. Therefore, disable the "uncaught error trap" at this point, via:

trap '' ERR

I will send you a more comprehensive patch in a few days, when it is polished. Thanks!

cleanup
error "$2"
exit $1

}

#
Expand Down
7 changes: 2 additions & 5 deletions contrib/lbuild/lbuild
Expand Up @@ -235,7 +235,7 @@ Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
Builds a Xen domX kernel.
--set-value
Set's a variable to a given value.
Sets a variable to a given value.
EOF

Expand Down Expand Up @@ -1787,10 +1787,7 @@ else
seen_list=$(add_list "$seen_list" "${BASH_SOURCE[0]}:${BASH_LINENO[0]}")
fi
backtrace
echo
echo "Environment:"
set
) | mail -s "Untrapped error at ${BASH_SOURCE[0]##*/}:$((LINENO-15)) on $HOSTNAME" brian@whamcloud.com >&2; set $xtrace' ERR
) ; set $xtrace' ERR
set -E

[ -r ~/.lbuildrc ] && . ~/.lbuildrc
Expand Down

0 comments on commit dcce9cc

Please sign in to comment.