Project

General

Profile

« Previous | Next » 

Revision 9104

lib/sh/util.sh: limit_stderr_cmd(): moved stdout2stderr code to limit_stderr() because it is not specific to running limit_stderr on single commands

View differences:

util.sh
191 191

  
192 192
echo_run() { cmd2rel_path; echo_cmd "$@"; indent; "$@"; }
193 193

  
194
# usage: (limit_stderr; cmd...) || return
194
# usage: ([stdout2stderr=1] limit_stderr; cmd...) || return
195 195
# `|| return` needed on Mac because of bug where -e doesn't apply to ()
196
limit_stderr() { inc_log_level; if ! can_log; then exec 2>/dev/null; fi; }
196
limit_stderr()
197
{
198
	inc_log_level
199
	if ! can_log; then exec 2>/dev/null; fi
200
	if test "$stdout2stderr"; then stdout2stderr; fi
201
}
197 202

  
198 203
limit_stderr_cmd() # usage: [stdout2stderr=1] limit_stderr_cmd cmd...
199 204
{
200 205
	case "$1" in echo_run) shift; cmd2rel_path; echo_cmd "$@";; esac
201
	(limit_stderr
202
		if test "$stdout2stderr"; then stdout2stderr; fi
203
		indent; "$@"
204
	) || return
206
	(limit_stderr; indent; "$@") || return
205 207
}
206 208
alias limit_stderr_cmd='limit_stderr_cmd ' # last space alias-expands next word
207 209

  

Also available in: Unified diff