summaryrefslogtreecommitdiffstats
path: root/mkinitcpio
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 /mkinitcpio
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 'mkinitcpio')
-rwxr-xr-xmkinitcpio15
1 files changed, 7 insertions, 8 deletions
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