[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 18:54:08 EDT 2011


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


More information about the arch-projects mailing list