Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: _pgrep improvements for Solaris
- X-seq: zsh-workers 32505
- From: Danek Duvall <duvall@xxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: _pgrep improvements for Solaris
- Date: Tue, 25 Mar 2014 15:04:24 -0700
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mail-followup-to: Danek Duvall <duvall@xxxxxxxxxxxxxx>, zsh-workers@xxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author