Project

General

Profile

« Previous | Next » 

Revision 9231

: use new `params` in all functions that have keyword params, in order to remove their vars from the environment. note that functions that use $? (such as die()) must save it *before running params, because params will overwrite $?.

View differences:

util.sh
227 227
log_e() { log_err "command exited with error $e"; }
228 228

  
229 229
# usage: cmd || [type=...] die msg
230
die() { save_e; "log_${type:-err}" "$1"; rethrow; }
230
die() { save_e; params type; "log_${type:-err}" "$1"; rethrow; }
231 231

  
232 232

  
233 233
### command echoing
......
256 256
function command() # usage: [cmd_log_fd=|1|2|#] command extern_cmd...
257 257
# to view only explicitly-displayed errors: explicit_errors_only=1 script...
258 258
{
259
	params cmd_log_fd
260
	
259 261
	cmd2rel_path; (echo_params; can_log) && indent || true
260 262
	(
261 263
		# the following redirections must happen in exactly this order
......
280 282
function echo_func() # usage: [minor=1] "echo_func" "$@" && indent || true
281 283
# exit status: whether function call was echoed
282 284
{
285
	params minor
286
	
283 287
	log++; if test "$minor"; then log++; fi
284 288
	local script="$(canon_rel_path "${BASH_SOURCE[1]}")"
285 289
	echo_cmd "$script:${BASH_LINENO[0]}" "${FUNCNAME[1]}" "$@"
......
340 344

  
341 345
set_fd() # usage: dest=fd dir='[<>]' src=fd [noclobber=1] set_fd
342 346
{
343
	echo_func
347
	echo_func; params dest dir src
344 348
	: "${dest:?}" "${dir:?}" "${src:?}"
345 349
	test ! "$noclobber" || require_fd_not_exists "$dest" || return 0
346 350
	echo_eval exec "$dest$dir&$src"
......
414 418
# auto-removes a command's output file on error (like make's .DELETE_ON_ERROR)
415 419
function to_file() # usage: stdout=... [if_not_exists=1] to_file cmd...
416 420
{
417
	echo_func
421
	echo_func; params stdout
418 422
	: "${stdout?}"; echo_vars stdout
419 423
	test ! "$if_not_exists" || require_not_exists "$stdout" || return 0
420 424
	"$@" >"$stdout" || { save_e; log_e; rm "$stdout"; rethrow; }

Also available in: Unified diff