Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: _initctl: only define helper functions once
- X-seq: zsh-workers 29376
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: _initctl: only define helper functions once
- Date: Thu, 26 May 2011 18:05:23 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:subject:date:message-id:x-mailer :in-reply-to:references; bh=4F2WbRfPmA3M7TjPSN9qDllyXs76s+gC/LWEWA2oNIg=; b=rRsSSkM+uEe7n/jRnQ+2mGBmAL4ge+VR45v5xyJt/GBl9UHM6Wi9J8VAySfWgs5T6Z DZnDRHVrIUsIB/ruLhC+cn67gFV3b7oaFn3/XorzaXGkasONwielVmWf44oeg80TJLmM S96AOKvo007JjdrM3W1QxcVnqAJWpCAqeeEO0=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; b=YLTLDxYE8wuAH6K9kKXj9s/spBCWCEVP082ccbOfM4iezoLUps/D9JVCIZVjRs7RE4 zj7ti5HmpQS7sG3Gb7H9snHV9XH83aebGM6P5kHg7To9BP8ZU9iDTQeql5qKBFqNBUwF JeB6zzAsnrT2eueJb8ZIewMDedc8dpEEUhEGM=
- In-reply-to: <20110526103606.0d7cd39a@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20110526103606.0d7cd39a@pwslap01u.europe.root.pri>
---
Completion/Unix/Command/_initctl | 69 ++++++++++++++++++++------------------
1 files changed, 36 insertions(+), 33 deletions(-)
diff --git a/Completion/Unix/Command/_initctl b/Completion/Unix/Command/_initctl
index 08145b1..850064d 100644
--- a/Completion/Unix/Command/_initctl
+++ b/Completion/Unix/Command/_initctl
@@ -2,29 +2,6 @@
# Written by Bernhard Tittelbach
# based on completion script by Mildred
-local -a common_args
-common_args=(
- '--session[use D-Bus session bus to connect to init daemon (for testing)]'
- '--system[talk via DBUS system bus instead of socket]'
- '(-q --quiet)'{-q,--quiet}'[reduce output to errors only]'
- '(-v --verbose)'{-v,--verbose}'[increase output to include informational messages]'
- '--dest=[D-Bus name for init, defaults to com.ubuntu.Upstart]'
- '--help[display help and exit]'
- '--version[output version information and exit]'
-)
-
-# don't overwrite work that we might have already done
-if (( ${+_initctl_events_list} + ${+_initctl_eventargs_list} != 2 )); then
- typeset -g -a -U _initctl_events_list _initctl_eventargs_list
-fi
-
-# map each initctl function to a completion function
-local -A cmd_completion_funcs
-cmd_completion_funcs=( start startstop stop startstop restart startstop reload startstop show-config show-config status argjob emit emit check-config check-config )
-
-# define fallback completion function
-local cmd_completion_default=basic
-
# run show-config -e and if possible parse out all events and KEY= argumnts
# otherwise provide some common values
_initctl_fillarray_events_args ()
@@ -169,13 +146,39 @@ _initctl_check-config()
'*::'
}
-# depending on which command was used, call different completion funtions
-case $service in
- initctl)
- _arguments "${common_args[@]}" '*::Initctl Commands:_initctl_command'
- ;;
- start|stop|restart|reload|status)
- _call_function ret _initctl_${cmd_completion_funcs[${service}]-${cmd_completion_default}}
- ;;
- *) return 1 ;;
-esac
+_initctl()
+{
+ local -a common_args
+ common_args=(
+ '--session[use D-Bus session bus to connect to init daemon (for testing)]'
+ '--system[talk via DBUS system bus instead of socket]'
+ '(-q --quiet)'{-q,--quiet}'[reduce output to errors only]'
+ '(-v --verbose)'{-v,--verbose}'[increase output to include informational messages]'
+ '--dest=[D-Bus name for init, defaults to com.ubuntu.Upstart]'
+ '--help[display help and exit]'
+ '--version[output version information and exit]'
+ )
+
+ # don't overwrite work that we might have already done
+ if (( ${+_initctl_events_list} + ${+_initctl_eventargs_list} != 2 )); then
+ typeset -g -a -U _initctl_events_list _initctl_eventargs_list
+ fi
+
+ # map each initctl function to a completion function
+ local -A cmd_completion_funcs
+ cmd_completion_funcs=( start startstop stop startstop restart startstop reload startstop show-config show-config status argjob emit emit check-config check-config )
+
+ # define fallback completion function
+ local cmd_completion_default=basic
+
+ # depending on which command was used, call different completion funtions
+ case $service in
+ initctl)
+ _arguments "${common_args[@]}" '*::Initctl Commands:_initctl_command'
+ ;;
+ start|stop|restart|reload|status)
+ _call_function ret _initctl_${cmd_completion_funcs[${service}]-${cmd_completion_default}}
+ ;;
+ *) return 1 ;;
+ esac
+}
--
1.7.4-rc1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author