Commit f8b562f5 authored by Aleksey Midenkov's avatar Aleksey Midenkov

Scripts: capture_warnings.sh missed errors and exit status fix

parent 67cd92b6
#!/bin/bash
warn_path=$1
warn_mode=$2
warn_mode=$2 # 'late', 'early' or 'both'
shift 2
warn_file="$warn_path/compile.warnings"
......@@ -45,7 +45,7 @@ suppress_warnings()
unset from
if [[ $l =~ ^[[:space:]]*\^~*$ ]]
if [[ $l =~ ^[[:space:]]*~*\^~*$ ]]
then
cat "$suppress_file" | tr '\n' 'X' | /bin/grep -Gq "$m" ||
echo "$w"
......@@ -68,18 +68,19 @@ suppress_warnings()
}
exec 3>&1
cmderr=$("$@" 2>&1 1>&3 | suppress_warnings) || {
error=${PIPESTATUS}
echo "$cmderr" >&2
exit $error
}
if [[ -n "$cmderr" ]]; then
[[ "$warn_mode" != "late" || "$cmderr" =~ error: ]] &&
echo "$cmderr" >&2
[[ "$warn_mode" != "early" && "$cmderr" =~ (warning|note): ]] &&
echo "$cmderr" >> "$warn_file"
fi
"$@" 2>&1 1>&3 | suppress_warnings | (
cmderr=`cat`
true
if [[ -n "$cmderr" ]]; then
if [[ "$cmderr" =~ error: ]]; then
echo "$cmderr" >&2
exit
fi
[[ "$warn_mode" != "late" ]] &&
echo "$cmderr" >&2
[[ "$warn_mode" != "early" && "$cmderr" =~ (warning|note): ]] &&
echo "$cmderr" >> "$warn_file"
fi
)
exit ${PIPESTATUS}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment