summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2015-05-11 12:11:25 +0200
committerOliver Kiddle <opk@zsh.org>2015-05-11 12:11:32 +0200
commit5b7e50dcd0786a47e180499c9a7a28cffcd73c1d (patch)
tree087dd99331442b8b24825477262f723216d22f98
parentd756f4eafd5d9f5fb3125d88d6a8b703b3ab6078 (diff)
downloadzsh-5b7e50dcd0786a47e180499c9a7a28cffcd73c1d.tar.gz
zsh-5b7e50dcd0786a47e180499c9a7a28cffcd73c1d.zip
35049: allow jail completion to include jid 0 for the host and to
complete jails by any parameter
-rw-r--r--ChangeLog7
-rw-r--r--Completion/BSD/Type/_jails32
-rw-r--r--Completion/Unix/Command/_pgrep12
-rw-r--r--Completion/Unix/Command/_ps2
4 files changed, 39 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 9cfa8e943..5222027c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-05-11 Oliver Kiddle <opk@zsh.org>
+
+ * 35049 (tweaked to make jname default): Completion/BSD/Type/_jails,
+ Completion/Unix/Command/_ps, Completion/Unix/Command/_pgrep:
+ allow jail completion to include jid 0 for the host and to complete
+ jails by any parameter
+
2015-05-11 Peter Stephenson <p.stephenson@samsung.com>
* 35078: Src/zsh.h, Test/D04parameter.ztst: also quote backslash
diff --git a/Completion/BSD/Type/_jails b/Completion/BSD/Type/_jails
index 36bffeceb..89e34ba4f 100644
--- a/Completion/BSD/Type/_jails
+++ b/Completion/BSD/Type/_jails
@@ -1,5 +1,33 @@
#autoload
-jails=( ${${${${(f)"$(_call_program jails jls -n)"}##*jid=}/ name=/:}%% *} )
+# Options:
+#
+# -0 include jid 0 as a match for the host system
+# -o param jail parameter to complete instead of jid -
+# e.g. name, path, ip4.addr, host.hostname
-_describe -t jails jail jails "$@"
+local addhost host param desc=1
+local -a jails args expl
+zparseopts -D -K -E 0=addhost o:=param
+param=${param[2]:-name}
+
+jails=( ${${(f)"$(_call_program jails jls $param name)"}/ /:} )
+case $param in
+ jid) host=0 ;;
+ name)
+ host=0
+ desc=0
+ ;;
+ path)
+ host=/
+ args=( -M 'r:|/=* r:|=*' )
+ ;;
+ ip4.addr) args=( -M 'r:|.=* r:|=*' ) ;;
+esac
+[[ -n $addhost && -n $host ]] && jails+=( "$host:$HOST" )
+
+if (( desc )); then
+ _describe -t jails jail jails "$@" "$args[@]"
+else
+ _wanted jails expl jail compadd "$@" "$args[@]" - ${jails%:*}
+fi
diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep
index 3af55a379..d3dcd1812 100644
--- a/Completion/Unix/Command/_pgrep
+++ b/Completion/Unix/Command/_pgrep
@@ -8,7 +8,7 @@ arguments=('-P[parent process id]:parent process id:->ppid'
'-F[match only in process in pidfile]:files:_files'
'-g[match only in process group ids]:group:->pgid'
'-G[match only real group id]:group:_groups'
- '-j[match only in processes inside jails]:jail id:->jid'
+ '-j[match only in processes inside jails]:jail id:_sequence _jails -0 -o jid'
'-J[match only in project ids]:project id:->projid'
'-M[extract the name list from the specified core]:files:_files'
'-N[extract the name list from the specified system]:files:_files'
@@ -93,16 +93,6 @@ case $state in
_wanted sid expl 'session id' compadd -S ',' -q -F used $sid
;;
- (jid)
- compset -P '*,'
-
- local -a used jid
- used=(${(s:,:)IPREFIX})
- jid=(${(uon)$(ps -ax -o jid=)})
-
- _wanted jid expl 'jail id' compadd -S ',' -q -F used $jid
- ;;
-
(ppid)
compset -P '*,'
diff --git a/Completion/Unix/Command/_ps b/Completion/Unix/Command/_ps
index 925f48390..e557b27b9 100644
--- a/Completion/Unix/Command/_ps
+++ b/Completion/Unix/Command/_ps
@@ -160,7 +160,7 @@ if (( CURRENT > 1 )) && [[ $OSTYPE != solaris* || ( $OSTYPE = linux-gnu && $word
_wanted -C option-k-1 properties expl 'property' _sequence -s , _ps_props -s - && return
;;
*G) _sequence -s , _groups && return ;;
- *J) _sequence -s , _jails && return ;;
+ *J) _sequence _jails -0 && return ;;
*[MNW]) _files && return ;;
*t)
_wanted -C option-t-1 ttys expl tty _sequence -s , \