File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -850,12 +850,21 @@ then
850850 }
851851fi
852852
853+ # `_bash-it-find-in-ancestor` uses the shell's ability to run a function in
854+ # a subshell to simplify our search to a simple `cd ..` and `[[ -r $1 ]]`
855+ # without any external dependencies. Let the shell do what it's good at.
853856function _bash-it-find-in-ancestor() (
854- # We're deliberately using a subshell for this entire function for simplicity.
855- # By using a subshell, we can use ${PWD} without special handling, and can
856- # just `cd ..` to move up the directory heirarchy.
857- # Let the shell do the work.
857+ about ' searches parents of the current directory for any of the specified file names'
858+ group ' helpers'
859+ param ' *: names of files or folders to search for'
860+ returns ' 0: prints path to matching parent directory to stdout'
861+ returns ' 1: no match found'
862+ returns ' 2: improper usage of shell builtin' # uncommon
863+ example ' _bash-it-find-in-ancestor .git .hg'
864+ example ' _bash-it-find-in-ancestor GNUmakefile Makefile makefile'
865+
858866 local kin
867+ # To keep things simple, we do not search the root dir.
859868 while [[ " ${PWD} " != ' /' ]]; do
860869 for kin in " $@ " ; do
861870 if [[ -r " ${PWD} /${kin} " ]]; then
You can’t perform that action at this time.
0 commit comments