[arch-projects] [MKINITCPIO][PATCH 1/2] 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 No such hook: sex Signed-off-by: Sebastien Luttringer <seblu@seblu.net> --- mkinitcpio | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mkinitcpio b/mkinitcpio index 4082ba5..6be7fbd 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -118,8 +118,9 @@ 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) [[ ! -r "${INSTDIR}/${OPTARG}" ]] && echo "No such hook: ${OPTARG}" && exit 1 + . "${INSTDIR}/${OPTARG}"; + echo "Help for hook '${OPTARG}':" help exit 0 ;; L) msg "Available hooks" -- Sebastien "Seblu" Luttringer
It's annoying to remember the name of preset each time Signed-off-by: Sebastien Luttringer <seblu@seblu.net> --- Makefile | 1 + bash-completion | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-) create mode 100644 bash-completion diff --git a/Makefile b/Makefile index b77e088..4068f23 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,7 @@ install: all install -m644 -t ${DESTDIR}/etc/mkinitcpio.d mkinitcpio.d/* install -m644 mkinitcpio.5 ${DESTDIR}/usr/share/man/man5/mkinitcpio.5 + install -m644 bash-completion ${DESTDIR}/etc/bash_completion.d/mkinitcpio doc: mkinitcpio.5 mkinitcpio.5: mkinitcpio.5.txt diff --git a/bash-completion b/bash-completion new file mode 100644 index 0000000..49cd99e --- /dev/null +++ b/bash-completion @@ -0,0 +1,20 @@ +# mkinitcpio bash completion by Seblu <seblu@seblu.net> + +_mkinitcpio () +{ + local action="-c -k -s -b -g -a -p -m -S -v -M -L -H -h" + local cur="${COMP_WORDS[COMP_CWORD]}" + local caction="${COMP_WORDS[COMP_CWORD-1]}" + case "$caction" in + -c|-g|-s|-a) COMPREPLY=($(compgen -f -- $cur));; + -k) COMPREPLY=($(cd /lib/modules && compgen -d -- $cur));; + -b) COMPREPLY=($(compgen -d "$cur" -- $cur));; + -p) COMPREPLY=($(cd /etc/mkinitcpio.d/ && compgen -X '!*.preset' -f -- $cur|sed 's/\.preset//'));; + -H|-S) COMPREPLY=($(cd /lib/initcpio/install/ && compgen -f -- $cur));; + -m) COMPREPLY=();; + *) COMPREPLY=($(compgen -W "${action}" -- "$cur"));; + esac +} +complete -F _mkinitcpio mkinitcpio + +# vim: set ts=2 sw=2 ft=sh noet: -- Sebastien "Seblu" Luttringer
participants (1)
-
Sebastien Luttringer