From 78fb526649cc730d9c20be47112db945a4a8427b Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 24 Nov 2012 20:39:46 -0500 Subject: 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 --- mkinitcpio | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'mkinitcpio') diff --git a/mkinitcpio b/mkinitcpio index 7c75572..fbcef82 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -12,8 +12,8 @@ shopt -s extglob # needed files/directories _f_functions=functions _f_config=mkinitcpio.conf -_d_hooks=(hooks /usr/lib/initcpio/hooks /lib/initcpio/hooks) -_d_install=(install /usr/lib/initcpio/install /lib/initcpio/install) +_d_hooks="$PWD/hooks:/usr/lib/initcpio/hooks:/lib/initcpio/hooks" +_d_install="$PWD/install:/usr/lib/initcpio/install:/lib/initcpio/install" _d_presets=mkinitcpio.d # options and runtime data @@ -315,8 +315,7 @@ while :; do unset skip ;; -H|--hookhelp) shift - if script=$(find_in_dirs "$1" "${_d_install[@]}"); then - . "$script" + if PATH=$_d_install . "$1"; then if ! declare -f help >/dev/null; then error "No help for hook $1" exit 1 @@ -327,11 +326,12 @@ while :; do fi msg "Help for hook '$1':" help - list_hookpoints "$script" + list_hookpoints "$1" exit 0 ;; -L|--listhooks) msg "Available hooks" - for dir in "${_d_install[@]}"; do + IFS=: read -ra _dirs <<<"$_d_install" + for dir in "${_dirs[@]}"; do ( cd "$dir" &>/dev/null && printf ' %s\n' * ) done | sort -u | column -c$(tput cols) exit 0 ;; @@ -400,8 +400,7 @@ fi if (( _optshowautomods )); then msg "Modules autodetected" - _f_autodetect_hook=$(find_in_dirs 'autodetect' "${_d_install[@]}") - . "$_f_autodetect_hook" + PATH=$_d_install . 'autodetect' build printf '%s\n' "${!_autodetect_cache[@]}" | sort cleanup 0 -- cgit v1.2.3-24-g4f1b