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

Sebastien Luttringer seblu at seblu.net
Sat Jun 18 01:04:26 EDT 2011


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



More information about the arch-projects mailing list