summaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-11-25 02:39:46 +0100
committerDave Reisner <dreisner@archlinux.org>2012-11-26 02:08:57 +0100
commit78fb526649cc730d9c20be47112db945a4a8427b (patch)
treeca02d1169cacbd9e88d54cd5152d4ece89a722ee /functions
parentb9d81a088ad0aa694b335118cf4ee70ad3ad1712 (diff)
downloadmkinitcpio-78fb526649cc730d9c20be47112db945a4a8427b.tar.gz
mkinitcpio-78fb526649cc730d9c20be47112db945a4a8427b.tar.xz
replace find_in_dirs with PATH= manipulation
Declaring our lookup paths like normal colon delimited PATHs lets us reuse them for builtins like source and type to do the same work that this function previously did. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'functions')
-rw-r--r--functions23
1 files changed, 5 insertions, 18 deletions
diff --git a/functions b/functions
index e79d057..f46a9ae 100644
--- a/functions
+++ b/functions
@@ -202,11 +202,11 @@ funcgrep() {
}
list_hookpoints() {
- local funcs
+ local funcs script
- [[ -e ${1/install/hooks} ]] || return 0
+ script=$(PATH=$_d_hooks type -p "$1") || return 0
- mapfile -t funcs < <(funcgrep '^run_[[:alnum:]_]+' "${1/install/hooks}")
+ mapfile -t funcs < <(funcgrep '^run_[[:alnum:]_]+' "$script")
echo
msg "This hook has runtime scripts:"
@@ -455,7 +455,7 @@ add_runscript() {
local funcs fn script hookname=${BASH_SOURCE[1]##*/}
- if ! script=$(find_in_dirs "$hookname" "${_d_hooks[@]}"); then
+ if ! script=$(PATH=$_d_hooks type -p "$hookname"); then
error "runtime script for \`%s' not found" "$hookname"
return
fi
@@ -564,19 +564,6 @@ parse_config() {
} >"$BUILDROOT/config"
}
-find_in_dirs() {
- local dir
-
- for dir in "${@:2}"; do
- if [[ -e $dir/$1 ]]; then
- printf '%s' "$dir/$1"
- return 0
- fi
- done
-
- return 1
-}
-
initialize_buildroot() {
# creates a temporary directory for the buildroot and initialize it with a
# basic set of necessary directories and symlinks
@@ -616,7 +603,7 @@ run_build_hook() {
local MODULES= BINARIES= FILES= SCRIPT=
# find script in install dirs
- if ! script=$(find_in_dirs "$hook" "${_d_install[@]}"); then
+ if ! script=$(PATH=$_d_install type -p "$hook"); then
error "Hook '$hook' cannot be found"
return 1
fi