Project

General

Profile

« Previous | Next » 

Revision 8289

lib/util.run: Run run_cmd at shell exit (using trap) instead of requiring every runscript to have `run_cmd ` at the end of it

View differences:

inputs/GBIF/table.run
17 17
	MySQL_export
18 18
	"$(dirname "${BASH_SOURCE[0]}")"/../../lib/table.run "$FUNCNAME"
19 19
}
20

  
21
run_cmd "$@"
inputs/GBIF/raw_occurrence_record/run
1 1
#!/bin/bash
2 2
set -o errexit
3 3
. "$(dirname "${BASH_SOURCE[0]}")"/../table.run
4

  
5
run_cmd "$@"
inputs/GBIF/_MySQL/run
7 7
	echo_func "$FUNCNAME" "$@"
8 8
	echo_run "$(dirname "${BASH_SOURCE[0]}")"/import
9 9
}
10

  
11
run_cmd "$@"
inputs/GBIF/run
9 9
	echo_func "$FUNCNAME" "$@"
10 10
	fwd "$FUNCNAME" "$@"
11 11
}
12

  
13
run_cmd "$@"
lib/table.run
13 13
	"$(dirname "${BASH_SOURCE[0]}")"/path/to/table.run import
14 14
	after_import_cmds
15 15
}
16

  
17
run_cmd "$@"
18 16
fi ####
19 17

  
20 18
. "$(dirname "${BASH_SOURCE[0]}")"/util.run
......
91 89
	postprocess
92 90
	mk_derived
93 91
}
94

  
95
run_cmd "$@"
lib/util.run
17 17
	"$(dirname "${BASH_SOURCE[1]}")"/path_relative_to_caller
18 18
	"$top_dir"/path_relative_to_outermost_script
19 19
}
20

  
21
run_cmd "$@"
22 20
fi ####
23 21

  
24 22
echo_cmd () { echo "$PS4$*" >&2; }
......
36 34

  
37 35
run_cmd ()
38 36
{
39
	# only if called in outermost script (+1 for this script)
40
	if test "${#BASH_SOURCE[@]}" -eq 2; then
41
		test "$#" -ge 1 || usage "$0 cmd args" || return
42
		echo_cmd "$0" "$@"; "$@"
43
	fi
37
	set -- "${BASH_ARGV[@]}"
38
	test "$#" -ge 1 || usage "$0 cmd args" || return
39
	echo_cmd "$0" "$@"; "$@"
44 40
}
41
trap run_cmd EXIT
45 42

  
46 43
fwd () # usage: subdirs=(...); fwd "$FUNCNAME" "$@"
47 44
{
......
79 76
	)|echo_stdin|make --makefile=/dev/stdin \
80 77
self_dir="$(dirname "$(readlink -f "${BASH_SOURCE[1]}")")" "$@"
81 78
}
82

  
83
run_cmd "$@"

Also available in: Unified diff