From 3a65dbdaf17ff26691559fd224e66b2fbe3eee7c Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Sat, 18 Jun 2011 06:56:55 +0200 Subject: Fix printing of bash usage when asking for a bad hook 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 ==> ERROR: No hook sex Signed-off-by: Sebastien Luttringer --- mkinitcpio | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'mkinitcpio') diff --git a/mkinitcpio b/mkinitcpio index 4082ba5..bd1a4c8 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -118,8 +118,12 @@ while getopts ':c:k:sb:g:p:m:nvH:LMhS:t:z:' arg; do IFS=${OLDIFS} unset OLDIFS ;; - H) . "${INSTDIR}/${OPTARG}"; - msg "Help for hook '${OPTARG}'" + H) if [[ ! -r "${INSTDIR}/${OPTARG}" ]]; then + error "No hook ${OPTARG}" + exit 1 + fi + . "${INSTDIR}/${OPTARG}" + echo "Help for hook '${OPTARG}':" help exit 0 ;; L) msg "Available hooks" -- cgit v1.2.3-24-g4f1b From 643da24974067821638fd27d0f9685dffb525f21 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Sun, 26 Jun 2011 19:29:13 +0200 Subject: Print pretty message if no help is defined in hook Thanks to Dave Reisner for having suggested! Signed-off-by: Sebastien Luttringer --- mkinitcpio | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mkinitcpio') diff --git a/mkinitcpio b/mkinitcpio index bd1a4c8..a9c75ed 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -123,6 +123,10 @@ while getopts ':c:k:sb:g:p:m:nvH:LMhS:t:z:' arg; do exit 1 fi . "${INSTDIR}/${OPTARG}" + if [[ $(type -t help) != function ]]; then + error "No help for hook ${OPTARG}" + exit 1 + fi echo "Help for hook '${OPTARG}':" help exit 0 ;; -- cgit v1.2.3-24-g4f1b From 10986ecadeb7cc3ac39fa55f2c4a873b54323f2f Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Sun, 26 Jun 2011 20:19:04 +0200 Subject: Use error function instead of echo Signed-off-by: Sebastien Luttringer --- mkinitcpio | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mkinitcpio') diff --git a/mkinitcpio b/mkinitcpio index a9c75ed..7a30be0 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -137,9 +137,9 @@ while getopts ':c:k:sb:g:p:m:nvH:LMhS:t:z:' arg; do M) SHOW_AUTOMODS=1 ;; t) TMPDIR=$OPTARG ;; z) optcompress=$OPTARG ;; - :) echo "error: option requires an argument -- '$OPTARG'" >&2 + :) error "option requires an argument -- '$OPTARG'" >&2 exit 1 ;; - \?) echo "error: invalid option -- '$OPTARG'" >&2 + \?) error "invalid option -- '$OPTARG'" >&2 exit 1 ;; esac done -- cgit v1.2.3-24-g4f1b