Revision 12690
Added by Aaron Marcuse-Kubitza almost 11 years ago
trunk/lib/sh/util.sh | ||
---|---|---|
720 | 720 |
# usage: { stderr2stdout cmd|stdout_contains echo_run grep ...; } 41>&1 |
721 | 721 |
{ echo_func; pipe_delay; pipe_delay; "$@"|echo_stdout >/dev/null; } |
722 | 722 |
|
723 |
function stderr_matches() # usage: prep_try; if pattern=... "stderr_matches" \
|
|
724 |
# cmd...; then ...; fi; rethrow # manually rethrow any cmd error (if applicable)
|
|
723 |
stderr_matches() # usage: prep_try; if pattern=... "stderr_matches" cmd...; \
|
|
724 |
# then ...; fi; rethrow # manually rethrow any command error (if applicable)
|
|
725 | 725 |
# exit status of cmd is placed in $e for use with exception handling |
726 | 726 |
{ |
727 | 727 |
echo_func; kw_params pattern; : "${pattern?}" |
... | ... | |
731 | 731 |
e="${PIPESTATUS_[0]}" # 1st command's exit status -> $e |
732 | 732 |
return "${PIPESTATUS_[1]}" # 2nd command's exit status -> $? |
733 | 733 |
} |
734 |
alias stderr_matches='prep_try; "stderr_matches" ' |
|
735 |
# last space alias-expands next word |
|
736 | 734 |
|
737 | 735 |
fi # load new aliases |
738 | 736 |
if self_being_included; then |
... | ... | |
742 | 740 |
# *message*, rather than all error exit statuses |
743 | 741 |
{ |
744 | 742 |
echo_func; kw_params pattern; : "${pattern?}" |
745 |
stderr_matches "$@" || rethrow |
|
743 |
prep_try; stderr_matches "$@" || rethrow
|
|
746 | 744 |
} |
747 | 745 |
alias ignore_err_msg='"ignore_err_msg" ' # last space alias-expands next word |
748 | 746 |
|
trunk/lib/sh/db.sh | ||
---|---|---|
362 | 362 |
{ |
363 | 363 |
echo_func; : "${schema:?}"; mk_schema_esc |
364 | 364 |
prep_try; pattern='cannot create temporary relation in non-temporary schema' \ |
365 |
"stderr_matches" psql <<<"CREATE TEMP TABLE $schema_esc.t ()"
|
|
365 |
stderr_matches psql <<<"CREATE TEMP TABLE $schema_esc.t ()"
|
|
366 | 366 |
} |
367 | 367 |
|
368 | 368 |
pg_require_schema() # usage: schema=... pg_require_schema |
Also available in: Unified diff
lib/sh/util.sh: stderr_matches(): inline the stderr_matches alias to avoid needing to quote stderr_matches as "stderr_matches" in the most common use case (with pattern as a prefix env var)