Project

General

Profile

« Previous | Next » 

Revision 8994

lib/util.sh: renamed log_stderr* to limit_stderr* to reflect that stderr is limited (i.e. controlled) rather than logged

View differences:

lib/util.sh
96 96
alias dec_log_level='declare verbosity="$verbosity" PS4="${PS4#$log_indent}"
97 97
let verbosity++'
98 98

  
99
# usage: (log_stderr; cmd...) || return
99
# usage: (limit_stderr; cmd...) || return
100 100
# `|| return` needed on Mac because of bug where -e doesn't apply to ()
101
log_stderr () { if ! can_log; then exec 2>/dev/null; fi; }
101
limit_stderr () { if ! can_log; then exec 2>/dev/null; fi; }
102 102

  
103
log_stderr_cmd () # usage: [stdout2stderr=1] log_stderr_cmd cmd...
103
limit_stderr_cmd () # usage: [stdout2stderr=1] limit_stderr_cmd cmd...
104 104
{
105
	(log_stderr
105
	(limit_stderr
106 106
		if test -n "$stdout2stderr"; then stdout2stderr; fi
107 107
		"$@"
108 108
	) || return
......
115 115
# auto-echo common external commands
116 116
for cmd in rm; do alias "$cmd=echo_run $cmd"; done; unset cmd
117 117

  
118
# controls stderr of (and echoes) an external command
119
alias log_stderr_extern='echo_run log_stderr_cmd "extern" '
118
# limits stderr of (and echoes) an external command
119
alias limit_stderr_extern='echo_run limit_stderr_cmd "extern" '
120 120
	# last space alias-expands next word
121 121

  
122
# echo and control stderr of all external commands
123
alias extern="log_stderr_extern " # last space alias-expands next word
122
# echo and limit stderr of all external commands
123
alias extern="limit_stderr_extern " # last space alias-expands next word
124 124

  
125 125
alias self='extern "$FUNCNAME"' # usage: wrapper () { self ...; }
126 126

  

Also available in: Unified diff