Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tools/host-mkdep Perform shell fd gymnastics to capture the ...
details: https://anonhg.NetBSD.org/src/rev/a8928aa736ed
branches: trunk
changeset: 785396:a8928aa736ed
user: christos <christos%NetBSD.org@localhost>
date: Tue Mar 12 01:52:20 2013 +0000
description:
Perform shell fd gymnastics to capture the error in the pipeline and exit.
diffstat:
tools/host-mkdep/host-mkdep.in | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diffs (53 lines):
diff -r 301bcaad7228 -r a8928aa736ed tools/host-mkdep/host-mkdep.in
--- a/tools/host-mkdep/host-mkdep.in Mon Mar 11 23:17:34 2013 +0000
+++ b/tools/host-mkdep/host-mkdep.in Tue Mar 12 01:52:20 2013 +0000
@@ -1,6 +1,6 @@
#!@BSHELL@ -
#
-# $NetBSD: host-mkdep.in,v 1.24 2013/03/05 03:06:21 christos Exp $
+# $NetBSD: host-mkdep.in,v 1.25 2013/03/12 01:52:20 christos Exp $
#
# Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved.
@@ -69,6 +69,13 @@
fi
}
+# Send the command output to 4, and a command to set the exit code to 5
+exec 5>&1
+run_cmd() {
+ "$@" 1>&4 4>&-
+ echo rv=$? 1>&5 5>&-
+}
+
# A getopt compatible command line parser in shell comands.
# (don't trust the shell builtin getopts to be in a known state on error)
while [ $# -gt 0 ]; do
@@ -226,12 +233,13 @@
done <$f
done >$TMP
else
+ exec 5>&1
for f in $SRCS; do
file=${f##*/}
file=${file%.*}
set_objlist $file
- @CPP@ "$@" $f | @AWK@ '
+ eval $( (run_cmd @CPP@ "$@" $f 4>&1 | @AWK@ '
/^#/ {
# Be as tolerant as possible.
sub(/^#(line)? [ 0-9]*\"?/, "")
@@ -247,7 +255,11 @@
print "'"$objlist"'" ": " $0
'"$AWK_OPTIONAL"'
}
- ' >> $TMP
+ ' >> $TMP) 5>&1)
+ case "$rv" in
+ 0);;
+ *) exit $rv;;
+ esac
done
fi
Home |
Main Index |
Thread Index |
Old Index