An updated completion is attached which handles the "no wait" options for start(8) and stop(8) correctly.
Kind regards, James ----- Forwarded message from James Hunt <[email protected]> ----- Date: Thu, 25 Nov 2010 11:40:30 +0000 From: James Hunt <[email protected]> To: [email protected] Subject: new completion for "upstart" for review Hi All, Attached is a new bash completion I have written for the "upstart" init replacement (http://upstart.ubuntu.com). Please could this be added to the review queue. Thank you in advance. -- Kind regards, James Hunt ______________________________________________________________________ Ubuntu Foundations Team, Canonical. # bash-completion for the upstart event-based init replacement. # We don't provide completion for 'init' itself for obvious reasons. have initctl && _upstart_conf_events() { initctl list|awk '{print $1}' } && _upstart_named_events() { (cd /etc/init && grep '^emits ' *.conf|sed 's/^emits //g') } && _upstart_events() { (_upstart_conf_events;_upstart_named_events)|tr ' ' '\n'|sort -u } && _upstart_startable_events() { initctl list|cut -d\, -f1|awk '$2 == "stop/waiting" {print $1}' } && _upstart_stoppable_events() { initctl list|cut -d\, -f1|awk '$2 == "start/running" {print $1}' } && _upstart_initctl() { _get_comp_words_by_ref cur prev COMPREPLY=() case "$prev" in start) COMPREPLY=( $(compgen -W "$(_upstart_startable_events)" -- ${cur}) ) return 0 ;; stop) COMPREPLY=( $(compgen -W "$(_upstart_stoppable_events)" -- ${cur}) ) return 0 ;; emit) COMPREPLY=( $(compgen -W "$(_upstart_events)" -- ${cur}) ) return 0 ;; reload|restart|status) COMPREPLY=( $(compgen -W "$(_upstart_conf_events)" -- ${cur}) ) return 0 ;; --help|--version) COMPREPLY=() return 0 ;; esac opts="--help --version -q --quiet -v --verbose --system --dest=" cmds=$(initctl help|grep "^ [^ ]"|awk '{print $1}') COMPREPLY=( $(compgen -W "${opts} ${cmds}" -- ${cur}) ) } && complete -F _upstart_initctl initctl have start && _upstart_start() { COMPREPLY=() _get_comp_words_by_ref cur prev opts="--help --version -q --quiet -v --verbose --system --dest= \ -n --no-wait" case "$prev" in --help|--version) COMPREPLY=() return 0 ;; esac COMPREPLY=( $(compgen -W "$opts $(_upstart_startable_events)" -- ${cur}) ) return 0 } && complete -F _upstart_start start have stop && _upstart_stop() { COMPREPLY=() _get_comp_words_by_ref cur prev opts="--help --version -q --quiet -v --verbose --system --dest= \ -n --no-wait" case "$prev" in --help|--version) COMPREPLY=() return 0 ;; esac COMPREPLY=( $(compgen -W "$opts $(_upstart_stoppable_events)" -- ${cur}) ) return 0 } && complete -F _upstart_stop stop have restart && _upstart_restart() { COMPREPLY=() _get_comp_words_by_ref cur prev opts="--help --version -q --quiet -v --verbose --system --dest= \ -n --no-wait" case "$prev" in --help|--version) COMPREPLY=() return 0 ;; esac COMPREPLY=( $(compgen -W "$opts $(_upstart_events)" -- ${cur}) ) return 0 } && complete -F _upstart_restart restart have status && _upstart_status() { COMPREPLY=() _get_comp_words_by_ref cur prev opts="--help --version -q --quiet -v --verbose --system --dest=" case "$prev" in --help|--version) COMPREPLY=() return 0 ;; esac COMPREPLY=( $(compgen -W "$opts $(_upstart_events)" -- ${cur}) ) return 0 } && complete -F _upstart_status status have reload && _upstart_reload() { COMPREPLY=() _get_comp_words_by_ref cur prev opts="--help --version -q --quiet -v --verbose --system --dest=" case "$prev" in --help|--version) COMPREPLY=() return 0 ;; esac COMPREPLY=( $(compgen -W "$opts $(_upstart_events)" -- ${cur}) ) return 0 } && complete -F _upstart_reload reload ----- End forwarded message ----- -- Regards, James Hunt ______________________________________________________________________ Ubuntu Foundations Team, Canonical.
# bash-completion for the upstart event-based init replacement # (http://upstart.ubuntu.com / https://launchpad.net/upstart) # # We don't provide completion for 'init' itself for obvious reasons. have initctl && _upstart_conf_events() { initctl list|awk '{print $1}' } && _upstart_named_events() { (cd /etc/init && grep '^emits ' *.conf|sed 's/^emits //g') } && _upstart_events() { (_upstart_conf_events;_upstart_named_events)|tr ' ' '\n'|sort -u } && _upstart_startable_events() { initctl list|cut -d\, -f1|awk '$2 == "stop/waiting" {print $1}' } && _upstart_stoppable_events() { initctl list|cut -d\, -f1|awk '$2 == "start/running" {print $1}' } && _upstart_initctl() { _get_comp_words_by_ref cur prev COMPREPLY=() case "$prev" in start) COMPREPLY=( $(compgen -W "-n --no-wait $(_upstart_startable_events)" -- ${cur}) ) return 0 ;; stop) COMPREPLY=( $(compgen -W "-n --no-wait $(_upstart_stoppable_events)" -- ${cur}) ) return 0 ;; emit) COMPREPLY=( $(compgen -W "$(_upstart_events)" -- ${cur}) ) return 0 ;; reload|restart|status) COMPREPLY=( $(compgen -W "$(_upstart_conf_events)" -- ${cur}) ) return 0 ;; -n|--no-wait) # allow no wait after start/stop commands for cmd in start stop do cwords=${comp_wor...@]##} filtered_cwords=${comp_wor...@]##${cmd}} if [ "$filtered_cwords" != "$cwords" ] then COMPREPLY=( $(compgen -W "$(_upstart_${cmd}able_events)" -- ${cur}) ) return 0 fi done ;; --help|--version) COMPREPLY=() return 0 ;; esac opts="--help --version -q --quiet -v --verbose --system --dest=" cmds=$(initctl help|grep "^ [^ ]"|awk '{print $1}') COMPREPLY=( $(compgen -W "${opts} ${cmds}" -- ${cur}) ) } && complete -F _upstart_initctl initctl have start && _upstart_start() { COMPREPLY=() _get_comp_words_by_ref cur prev opts="--help --version -q --quiet -v --verbose --system --dest= \ -n --no-wait" case "$prev" in --help|--version) COMPREPLY=() return 0 ;; esac COMPREPLY=( $(compgen -W "$opts $(_upstart_startable_events)" -- ${cur}) ) return 0 } && complete -F _upstart_start start have stop && _upstart_stop() { COMPREPLY=() _get_comp_words_by_ref cur prev opts="--help --version -q --quiet -v --verbose --system --dest= \ -n --no-wait" case "$prev" in --help|--version) COMPREPLY=() return 0 ;; esac COMPREPLY=( $(compgen -W "$opts $(_upstart_stoppable_events)" -- ${cur}) ) return 0 } && complete -F _upstart_stop stop have restart && _upstart_restart() { COMPREPLY=() _get_comp_words_by_ref cur prev opts="--help --version -q --quiet -v --verbose --system --dest= \ -n --no-wait" case "$prev" in --help|--version) COMPREPLY=() return 0 ;; esac COMPREPLY=( $(compgen -W "$opts $(_upstart_events)" -- ${cur}) ) return 0 } && complete -F _upstart_restart restart have status && _upstart_status() { COMPREPLY=() _get_comp_words_by_ref cur prev opts="--help --version -q --quiet -v --verbose --system --dest=" case "$prev" in --help|--version) COMPREPLY=() return 0 ;; esac COMPREPLY=( $(compgen -W "$opts $(_upstart_events)" -- ${cur}) ) return 0 } && complete -F _upstart_status status have reload && _upstart_reload() { COMPREPLY=() _get_comp_words_by_ref cur prev opts="--help --version -q --quiet -v --verbose --system --dest=" case "$prev" in --help|--version) COMPREPLY=() return 0 ;; esac COMPREPLY=( $(compgen -W "$opts $(_upstart_events)" -- ${cur}) ) return 0 } && complete -F _upstart_reload reload
signature.asc
Description: Digital signature
_______________________________________________ Bash-completion-devel mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/bash-completion-devel
