Revision 13319
Added by Aaron Marcuse-Kubitza almost 11 years ago
trunk/lib/sh/util.sh | ||
---|---|---|
1089 | 1089 |
|
1090 | 1090 |
stderr2stdout() # usage: { stderr2stdout cmd...|use stderr...; } 41>&1 |
1091 | 1091 |
# **IMPORTANT**: fd 41 must later be redirected back to fd 1 |
1092 |
# unlike `2>&1`, logs stderr
|
|
1092 |
# unlike `2>&1`, keeps stderr going to stderr
|
|
1093 | 1093 |
# redirects the command stdout to fd 41 to avoid collision with stderr |
1094 | 1094 |
{ |
1095 | 1095 |
echo_func |
1096 |
# command causes log_fd to be re-filtered, so that stderr is also filtered. |
|
1097 |
# fd 2 is *not* redirected back to fd 2, to allow log-filtering out an |
|
1098 |
# otherwise-confusing benign error. |
|
1099 |
piped_cmd "$@" 2> >(log++ command tee /dev/fd/"$log_fd") >&41 |
|
1100 |
# redirects 2->{1,log_fd} |
|
1096 |
# fd 2 *must* be redirected back to fd 2, not log-filtered, in case there |
|
1097 |
# are other errors in addition to the benign error |
|
1098 |
piped_cmd "$@" 2> >(log++ echo_run tee /dev/fd/2) >&41 # redirects 2->{1,2} |
|
1101 | 1099 |
} |
1102 | 1100 |
|
1103 | 1101 |
stdout_contains() |
Also available in: Unified diff
bugfix: stderr2stdout(): fd 2 must be redirected back to fd 2, not log-filtered, in case there are other errors in addition to the benign error. this fixes a bug in pg_schema_exists(), where errors about the DB being down were not displayed because they were log-filtered out.