* PATCH: _pgrep improvements for Solaris
@ 2014-03-25 22:04 Danek Duvall
0 siblings, 0 replies; only message in thread
From: Danek Duvall @ 2014-03-25 22:04 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 359 bytes --]
With the recent improvements to _pgrep, I noticed that the completion
function wasn't working at all on Solaris, so I built on top of what was
there, and came up with the attached patch.
My only concern is calling ps as "ps -A -o hdr="; on Solaris, the -o option
requires a preceding dash, and I don't know whether it's allowed on other
OSes.
Thanks,
Danek
[-- Attachment #2: _pgrep.diff --]
[-- Type: text/plain, Size: 3748 bytes --]
diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep
index f06d26e..3b180ab 100644
--- a/Completion/Unix/Command/_pgrep
+++ b/Completion/Unix/Command/_pgrep
@@ -9,6 +9,7 @@ arguments=('-P[parent process id]:parent process id:->ppid'
'-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 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'
'-s[match only session id]:session id:->sid'
@@ -27,7 +28,8 @@ arguments=('-P[parent process id]:parent process id:->ppid'
'-q[do not write anything to standard output]'
'-S[search also in system processes]'
'-v[negate matching]'
- '-x[match exactly]')
+ '-x[match exactly]'
+ '-z[match only in zones]:zone:_zones')
if [[ $service == 'pkill' ]]; then
arguments+=('-'${^signals}'[signal]')
@@ -50,6 +52,13 @@ case "$OSTYPE" in
darwin*)
optchars="LafilnoqvxFGPUdgtu"
;;
+ solaris*)
+ optchars="flvxdnoPgsuUGJtTcz"
+ arguments=( ${arguments##-T*} )
+ arguments=( ${arguments##-c*} )
+ arguments+=( '-T[match only processes in task ids]:taskid:->task' )
+ arguments+=( '-c[match only processes in contract ids]:taskid:->contract' )
+ ;;
*)
optchars="flvxdnoPgsuUGt"
;;
@@ -82,7 +91,7 @@ case $state in
if [[ $OSTYPE == freebsd* ]]; then
sid=(${(uon)$(ps -ax -o sid=)})
else
- sid=(${(uon)$(ps -A o sid=)})
+ sid=(${(uon)$(ps -A -o sid=)})
fi
_wanted sid expl 'session id' compadd -S ',' -q -F used $sid
@@ -106,7 +115,7 @@ case $state in
if [[ $OSTYPE == (freebsd|openbsd|darwin)* ]]; then
ppid=(${(uon)$(ps -ax -o ppid=)})
else
- ppid=(${(uon)$(ps -A o ppid=)})
+ ppid=(${(uon)$(ps -A -o ppid=)})
fi
_wanted ppid expl 'parent process id' compadd -S ',' -q -F used $ppid
@@ -120,12 +129,42 @@ case $state in
if [[ $OSTYPE == (freebsd|openbsd|darwin)* ]]; then
pgid=(${(uon)$(ps -ax -o pgid=)})
else
- pgid=(${(uon)$(ps -A o pgid=)})
+ pgid=(${(uon)$(ps -A -o pgid=)})
fi
_wanted pgid expl 'process group id' compadd -S ',' -q -F used $pgid
;;
+ (projid)
+ compset -P '*,'
+
+ local -a used projid
+ used=(${(s:,:)IPREFIX})
+ projid=(${(uon)$(ps -A -o project=)})
+
+ _wanted projid expl 'project id' compadd -S ',' -q -F used $projid
+ ;;
+
+ (contract)
+ compset -P '*,'
+
+ local -a used ctid
+ used=(${(s:,:)IPREFIX})
+ ctid=(${(uon)$(ps -A -o ctid=)})
+
+ _wanted ctid expl 'contract id' compadd -S ',' -q -F used $ctid
+ ;;
+
+ (task)
+ compset -P '*,'
+
+ local -a used taskid
+ used=(${(s:,:)IPREFIX})
+ taskid=(${(uon)$(ps -A -o project=)})
+
+ _wanted taskid expl 'task id' compadd -S ',' -q -F used $taskid
+ ;;
+
(pname)
local ispat="pattern matching "
if (( ${+opt_args[-x]} )); then
@@ -138,6 +177,8 @@ case $state in
command="$(ps -axH -o command=)"
elif [[ "$OSTYPE" == (freebsd|openbsd|darwin)* ]]; then
command="$(ps -ax -o command=)"
+ elif [[ "$OSTYPE" == solaris* ]]; then
+ command="$(ps -A -o args=)"
else
command="$(ps -A o cmd=)"
fi
@@ -147,6 +188,8 @@ case $state in
command="$(ps -axcH -o command=)"
elif [[ "$OSTYPE" == (freebsd|openbsd|darwin)* ]]; then
command="$(ps -axc -o command=)"
+ elif [[ "$OSTYPE" == solaris* ]]; then
+ command="$(ps -A -o comm=)"
else
command="$(ps -A co cmd=)"
fi
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-03-25 22:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-25 22:04 PATCH: _pgrep improvements for Solaris Danek Duvall
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).