Added gitignore entries needed to ignore derived objects generated from full build...
[bash.git] / examples / scripts.noah / source.bash
blob2b3648933c39a623e7101960997d152986acf6be
1 # source.bash
2 # Author: Noah Friedman <friedman@prep.ai.mit.edu>
3 # Created: 1992-05-17
4 # Last modified: 1993-09-29
5 # Public domain
7 # Commentary:
8 # Code:
10 #:docstring source:
11 # Usage: source file ...
13 # Source forces file arguments to be considered in the current directory
14 # only, unless there is an absolute path starting with `/'. I think it's
15 # bad that the builtin "source" searches PATH, because PATH normally
16 # contains directories with binary files that aren't useful for bash to
17 # read and most people don't put "." first in their path.
19 # This "source" is capable of reading more than one file at a time. Return
20 # value is number of failed source attempts.
21 #:end docstring:
23 # This function is not hygienic, but there's not much we can do about
24 # variable name conflicts here.
26 ###;;;autoload
27 function source ()
29 local -i _source_failure_count=0
30 local _source_file
32 for _source_file ; do
33 # Check first part of each filename. If it's not `/', `./', or
34 # `../' then prepend "./" to the path to force the builtin `source'
35 # not to go searching through PATH to find the file.
36 case "${_source_file}" in
37 /*|./*|../* ) ;;
38 * ) _source_file="./${_source_file}" ;;
39 esac
41 builtin source "${_source_file}" ||
42 _source_failure_count="_source_failure_count + 1"
44 done
46 return ${_source_failure_count}
49 #:docstring .:
50 # See "source"
51 #:end docstring:
53 # So that `.' will call function definition of `source' instead of builtin
55 ###;;;autoload
56 function . ()
58 source "$@"
61 provide source
63 # source.bash ends here