Project

General

Profile

« Previous | Next » 

Revision 8793

lib/util.sh: self_not_included (): added support for loading newly-defined aliases for use in functions in the same file, and documentation for how to do this

View differences:

lib/util.sh
7 7
{
8 8
	test "$#" -ge 1 || set -- "${BASH_SOURCE[1]}"
9 9
	local include_guard="$(include_guard_var "$1")"
10
	test -z "${!include_guard+t}" && eval "$include_guard"=1
10
	alias self_being_included=false
11
	test -z "${!include_guard+t}" && \
12
	{ eval "$include_guard"=1; alias self_being_included=true; }
11 13
}
12 14

  
15
# to load newly-defined aliases for use in functions in the same file:
16
## fi # load new aliases
17
## if self_being_included; then
18
# this is needed because aliases defined inside an if statement are not
19
# available inside that if statement
20

  
13 21
if self_not_included "${BASH_SOURCE[0]}"; then
14 22

  
15 23
shopt -s expand_aliases

Also available in: Unified diff