]> git.draconx.ca Git - dxcommon.git/commitdiff
exported.sh: Improve error handling.
authorNick Bowler <nbowler@draconx.ca>
Wed, 29 Aug 2012 00:38:53 +0000 (20:38 -0400)
committerNick Bowler <nbowler@draconx.ca>
Wed, 29 Aug 2012 00:38:53 +0000 (20:38 -0400)
Use the eval trick to handle errors from commands in the pipeline other
than the last.  In particular, we now detect if nm failed and return an
error status in this case.  While we're rewriting this code, replace
sort | uniq with sort -u as the latter should be fine according to
POSIX.  We can re-add the two-command version if it actually causes
problems.

snippet/exported.sh.in

index 762600ac9cdf25cad96da807efc5da604ccf14f6..ef875a55f3ddd500be41a9a5db4beef24a712afc 100644 (file)
@@ -1,6 +1,6 @@
 #!@SHELL@
 #
-# Copyright © 2011 Nick Bowler
+# Copyright © 2011-2012 Nick Bowler
 #
 # Determine the list of exported symbols from archives or (libtool) object
 # files.
@@ -40,5 +40,19 @@ done
 set x $OBJS; shift
 case $# in
 0) : ;;
-*) @NM@ $OBJS | @GLOBAL_SYMBOL_PIPE@ | @SED@ 's/^.* //' | sort | uniq ;;
+*)
+       exec 4>&1
+       eval_cmd=`exec 3>&1
+               { @NM@ $OBJS 3>&-
+                       echo "(exit $?) || exit $?" >&3
+               } | { @GLOBAL_SYMBOL_PIPE@ 3>&-
+                       echo "(exit $?) || exit $?" >&3
+               } | { @SED@ 's/^.* //' 3>&-
+                       echo "(exit $?) || exit $?" >&3
+               } | { sort -u 3>&-
+                       echo "(exit $?) || exit $?" >&3
+               } >&4`
+       exec 4>&-
+       eval "$eval_cmd"
+;;
 esac