summaryrefslogtreecommitdiff
path: root/etc/functions/xsource
blob: 50ad5beefa1638b721e8d94013d03b63c010db3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
## vim:ft=zsh
# Note: This function's behaviour differs hrom source.
# With source, parameters declared local are available to the sourcing script.
# With xsource, parameters declared local will NOT be available unless you use
# eval $(xsource -e file)
typeset -i eval=0

while [[ $1 == -* ]] {
	case $1 in
		-e) eval=1 ;;
	esac
	shift
}


if [[ -r $1 ]] {
	if (( eval )) {
		echo source $1
	} else {
		source $1
	}
}