[arch-projects] [MKINITCPIO][PATCH 1/2] Fix printing of bash usage when asking for a bad hook

Seblu seblu at seblu.net
Sun Jun 19 20:34:18 EDT 2011


On Mon, Jun 20, 2011 at 1:50 AM, Dave Reisner <d at falconindy.com> wrote:
> On Mon, Jun 20, 2011 at 12:54:08AM +0200, Seblu wrote:
>> On Mon, Jun 20, 2011 at 12:25 AM, Dave Reisner <d at falconindy.com> wrote:
>> > On Sat, Jun 18, 2011 at 07:04:26AM +0200, Sebastien Luttringer wrote:
>> >> before:
>> >> mkinitcpio -H sex
>> >> /sbin/mkinitcpio: line 105: /lib/initcpio/install/sex: No such file or directory
>> >> Help for hook 'sex':
>> >> GNU bash, version 4.2.10(2)-release (x86_64-unknown-linux-gnu)
>> >> These shell commands are defined internally.  Type `help' to see this list.
>> >>
>> >> after:
>> >> mkinitcpio -H sex
>> >> No such hook: sex
>> >>
>> >> Signed-off-by: Sebastien Luttringer <seblu at seblu.net>
>> >> ---
>> >>  mkinitcpio |    3 ++-
>> >>  1 files changed, 2 insertions(+), 1 deletions(-)
>> >>
>> >> diff --git a/mkinitcpio b/mkinitcpio
>> >> index 70710eb..7b8f503 100755
>> >> --- a/mkinitcpio
>> >> +++ b/mkinitcpio
>> >> @@ -102,7 +102,8 @@ while getopts ':c:k:s:b:g:a:p:m:vH:LMhS:' arg; do
>> >>             IFS=${OLDIFS}
>> >>             unset OLDIFS
>> >>             ;;
>> >> -        H) . "${INSTDIR}/${OPTARG}";
>> >> +        H) [[ ! -r "${INSTDIR}/${OPTARG}" ]] && echo "No such hook: ${OPTARG}" && exit 1
>> >> +        . "${INSTDIR}/${OPTARG}";
>> >>             echo "Help for hook '${OPTARG}':"
>> >>             help
>> >>             cleanup
>> >> --
>> >> Sebastien "Seblu" Luttringer
>> >>
>> >
>> > If we're going to check this (and I agree we should -- was about to push
>> > my own patch), there should be a check to make sure 'help' exists as a
>> > function as well after sourcing the hook.
>> >
>> I asked but I said we should consider  hooks files valid because it's
>> like this everywhere in scripts.
>>
>> like here
>> if [ "${SHOW_AUTOMODS}" = "y" ]; then
>>     echo "Modules autodetected:"
>>     . "${INSTDIR}/autodetect"
>>     install
>>     cat "${MODULE_FILE}"
>>
>> --
>> Sébastien Luttringer
>> www.seblu.net
>
> An install hook isn't much without an install function (soon to be
> build, perhaps?). You can get away without defining a help function and
> still have a useful install hook.
>
ok right.


-- 
Sébastien Luttringer
www.seblu.net


More information about the arch-projects mailing list