Project

General

Profile

« Previous | Next » 

Revision 11414

lib/runscripts/util.run: support scripts that are run as shell-includes (with leading "."), by also accepting $@ args that are passed along in the util.run include, in addition to @BASH_ARGV

View differences:

lib/runscripts/util.run
6 6

  
7 7
if false; then #### run script template:
8 8
#!/bin/bash -e
9
. "$(dirname "${BASH_SOURCE[0]}")"/path/to/util.run or file_including_util.run
9
. "$(dirname "${BASH_SOURCE[0]}")"/path/to/util_or_file_including_util.run "$@"
10 10
.rel other_includes
11 11

  
12 12
cmd()
......
26 26

  
27 27
#### setup
28 28

  
29
include_args=("$@") # from `. .../util.run "$@"`
30

  
29 31
run_args_cmd() # runs the command line args command
30 32
{
31
	eval set -- "$(reverse "${BASH_ARGV[@]}")"
33
	set -- "${include_args[@]}"
34
	test $# -gt 0 || eval set -- "$(reverse "${BASH_ARGV[@]}")"
35
		# in case including script didn't pass along "$@"
32 36
	test $# -ge 1 || set -- all
33 37
	echo_cmd "$top_script" "$@"; time "$@"
34 38
}

Also available in: Unified diff