Project

General

Profile

1 8291 aaronmk
#!/bin/bash -e
2 8715 aaronmk
# runscripts: a bash-based replacement for make
3 8272 aaronmk
# unlike make, supports full bash functionality including multiline commands
4
# usage: path/to/dir/run cmd args
5
6
if false; then #### run script template:
7 8291 aaronmk
#!/bin/bash -e
8 8272 aaronmk
. "$(dirname "${BASH_SOURCE[0]}")"/path/to/util.run or file_including_util.run
9
. "$(dirname "${BASH_SOURCE[0]}")"/other_includes
10
11 9074 aaronmk
cmd()
12 8272 aaronmk
{
13 8881 aaronmk
	echo_func
14 8272 aaronmk
	"$(dirname "${BASH_SOURCE[0]}")"/path_relative_to_self
15
	"$(dirname "${BASH_SOURCE[1]}")"/path_relative_to_caller
16
	"$top_dir"/path_relative_to_outermost_script
17
}
18
fi ####
19
20 9507 aaronmk
. "$(dirname "${BASH_SOURCE[0]}")"/../sh/make.sh
21 9013 aaronmk
. "$(dirname "${BASH_SOURCE[0]}")"/../sh/util.sh
22 8703 aaronmk
23 8714 aaronmk
if self_not_included; then
24 8703 aaronmk
25 8972 aaronmk
# users can override run_args_cmd to perform other commands (or no commands)
26 8464 aaronmk
# after the script is read
27 9298 aaronmk
on_exit() { test $? -eq 0 || return; run_args_cmd; }
28 8464 aaronmk
trap on_exit EXIT
29
30 9268 aaronmk
func_override set_paths__util_sh
31
set_paths()
32 9267 aaronmk
{
33 9268 aaronmk
	set_paths__util_sh "$@"
34 9267 aaronmk
	top_file="${top_script%[./]run}"; echo_vars top_file
35
	top_filename="$(basename "$top_file")"; echo_vars top_filename
36
}
37 9268 aaronmk
set_paths
38 8988 aaronmk
39 8704 aaronmk
fi