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:

lib/sh/local.sh
36 36

  
37 37
psql() # usage: [file=...] [dir=...] self
38 38
{
39
	echo_func
39
	echo_func; params file dir
40 40
	if test "$file"; then
41 41
		set -- --file "$file" "$@"
42 42
		local dir="${dir:-$(dirname "$file")}"
lib/sh/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; }
lib/sh/db.sh
59 59

  
60 60
mysql() # usage: [output_data=1] mysql ...
61 61
{
62
	echo_func
62
	echo_func; params output_data
63 63
	set_database
64 64
	
65 65
	set -- ${database:+--database="$database" }--column-names "$@"
......
108 108

  
109 109
mysqldump() # usage: [schema=1 | data=1] mysqldump db [table...]
110 110
{
111
	echo_func
111
	echo_func; params schema data
112
	
112 113
	mysql_cmd ${database:+--databases "$database" --tables } \
113 114
--quick --lock-tables=false --set-charset \
114 115
${postgres_compat:+--compatible=postgresql --add-locks=false }\

Also available in: Unified diff