Project

General

Profile

« Previous | Next » 

Revision 9208

lib/sh/util.sh: added $err_fd global var and use it instead of the 22 magic value. it starts out at 2 until fd 22 has been set up, so commands that required 22 will now work before set_global_fds() is called.

View differences:

util.sh
142 142
#### verbose output
143 143

  
144 144

  
145
err_fd=2 # stderr
146

  
145 147
# usage: (stdout2stderr; cmd...) || return
146 148
# `|| return` needed on Mac because of bug where -e doesn't apply to ()
147 149
stdout2stderr() { exec >&2; }
......
184 186
# usage: symbol=... log_custom msg
185 187
log_custom() { local PS4="${PS4%[^ ] }$symbol "; log "$@"; }
186 188

  
187
log_err() { symbol=! verbosity=1 log_custom "$@" 2>&22; } #ensure errors visible
189
log_err() { symbol=! verbosity=1 log_custom "$@" 2>&"$err_fd"; }
188 190

  
189 191
log_info() { symbol=? log_custom "$@"; }
190 192

  
......
236 238
		# the following redirections must happen in exactly this order
237 239
		if test "$limit_stderr"; then limit_stderr; fi
238 240
		if test "$stdout2stderr"; then stdout2stderr; fi
239
		if test "$stderr_is_errors"; then exec 2>&22; fi # ensure errors visible
241
		if test "$stderr_is_errors"; then exec 2>&"$err_fd"; fi
240 242
		
241 243
		exec -- "$@" # -- so cmd name not treated as `exec` option
242 244
	) || return
......
338 340
	src=2 dir='>' shadow_fd || true
339 341
}
340 342
set_global_fds
343
err_fd=22 # global stderr
341 344

  
342 345
# usage: explicit_errors_only=1 script...
343 346
# show only explicitly-displayed errors (which have been redirected to fd 22)

Also available in: Unified diff