diff options
author | Thomas Bächler <thomas@archlinux.org> | 2011-06-26 23:18:44 +0200 |
---|---|---|
committer | Thomas Bächler <thomas@archlinux.org> | 2011-06-26 23:18:44 +0200 |
commit | 027ddb69122af89c89aa50906eec045f349c9490 (patch) | |
tree | f8350d984b5c3feee85f9613de4314d49d54aadb | |
parent | 60c079c11435e9e120cc6ebb991071e321b20639 (diff) | |
parent | f58be6cc8d802c4c48edd594aab41408df30e954 (diff) | |
download | mkinitcpio-027ddb69122af89c89aa50906eec045f349c9490.tar.gz mkinitcpio-027ddb69122af89c89aa50906eec045f349c9490.tar.xz |
Merge branch 'master' of https://github.com/seblu/arch-mkinitcpio into working
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | bash-completion | 32 | ||||
-rwxr-xr-x | mkinitcpio | 16 |
3 files changed, 45 insertions, 4 deletions
@@ -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 Makefile diff --git a/bash-completion b/bash-completion new file mode 100644 index 0000000..50cbb8e --- /dev/null +++ b/bash-completion @@ -0,0 +1,32 @@ +# mkinitcpio bash completion by Seblu <seblu@seblu.net> + +_lsinitcpio () +{ + local action="-a -h -v -x" + local cur="${COMP_WORDS[COMP_CWORD]}" + local caction="${COMP_WORDS[COMP_CWORD]}" + case "$caction" in + -*) COMPREPLY=($(compgen -W "${action}" -- "$cur"));; + *) _filedir;; + esac +} + +_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) _filedir;; + -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 +complete -F _lsinitcpio lsinitcpio + +# vim: set ts=2 sw=2 ft=sh noet: @@ -118,8 +118,16 @@ 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}" + if [[ $(type -t help) != function ]]; then + error "No help for hook ${OPTARG}" + exit 1 + fi + echo "Help for hook '${OPTARG}':" help exit 0 ;; L) msg "Available hooks" @@ -129,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 |