Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 2/3] _pgrep: fix commands used in completion
- X-seq: zsh-workers 32471
- From: Kosuke Asami <tfortress58@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 2/3] _pgrep: fix commands used in completion
- Date: Wed, 12 Mar 2014 02:04:07 +0900
- Cc: Kosuke Asami <tfortress58@xxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ib/ysO2jE6k/ZUR0KdpfjT3WnXZ872BDwo+PSuawz2A=; b=TGmFxypUHjYU13t+RjSJgUykeUIWqNhL6PYUtMSIl1Sf71nxcGLzb1lq43ZkNibLDb PKaUPwhh8DzAB3nuB9jwSqN9MKYtlZL2GkBTmVwMUrasR3xy/Boal5QzoEyarOM8hhd4 6Cq2E+FEYauaR0KeImiNYn1sY5WJ2yf4OdFIq5ZrnNdXsfBe3iHbKRdYFur9upyXGFoW 5v21IogUbJjwbydYS6D+a8dunwphtgQGhZ/Mk0wFbgnY+LzlO00kqFXItgNkCZbh2v6p AktI8jvL08a2B3k1FkdxBbwBGMA6ndWWx5dW7qTJowGVsXqdxtHsF8Q/yV3tlghejnhF +gjQ==
- In-reply-to: <1394557448-31011-1-git-send-email-tfortress58@gmail.com>
- 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: <1394557448-31011-1-git-send-email-tfortress58@gmail.com>
The option style in ps command are different between BSD and Linux.
For example, 'ps -A co cmd=' command cannot be executed in BSD
environment, so zsh completion always shows error like 'ps: illegal
argument: co' and cannot be used.
---
Completion/Unix/Command/_pgrep | 54 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 48 insertions(+), 6 deletions(-)
diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep
index e4bd2e2..15b1f44 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]'
+ '-j[match only in processes inside jails]:jail id:->jid'
'-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'
@@ -73,21 +73,43 @@ case $state in
;;
(sid)
+ if [[ $OSTYPE == openbsd* ]]; then
+ break
+ fi
+
compset -P '*,'
local -a used sid
used=(${(s:,:)IPREFIX})
- sid=(${(uon)$(ps -A o sid=)})
+ if [[ $OSTYPE == freebsd* ]]; then
+ sid=(${(uon)$(ps -ax -o sid=)})
+ else
+ sid=(${(uon)$(ps -A o sid=)})
+ fi
_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 '*,'
local -a used ppid
used=(${(s:,:)IPREFIX})
- ppid=(${(uon)$(ps -A o ppid=)})
+ if [[ $OSTYPE == (freebsd|openbsd|darwin)* ]]; then
+ ppid=(${(uon)$(ps -ax -o ppid=)})
+ else
+ ppid=(${(uon)$(ps -A o ppid=)})
+ fi
_wanted ppid expl 'parent process id' compadd -S ',' -q -F used $ppid
;;
@@ -97,7 +119,11 @@ case $state in
local -a used pgid
used=(${(s:,:)IPREFIX})
- pgid=(${(uon)$(ps -A o pgid=)})
+ if [[ $OSTYPE == (freebsd|openbsd|darwin)* ]]; then
+ pgid=(${(uon)$(ps -ax -o pgid=)})
+ else
+ pgid=(${(uon)$(ps -A o pgid=)})
+ fi
_wanted pgid expl 'process group id' compadd -S ',' -q -F used $pgid
;;
@@ -108,11 +134,27 @@ case $state in
then
ispat=""
fi
+
+ local command
if (( ${+opt_args[-f]} ))
then
- _wanted pname expl $ispat'process command line' compadd ${(u)${(f)"$(ps -A o cmd=)"}}
+ if [[ "$OSTYPE" == freebsd* ]] && (( ${+opt_args[-S]} )); then
+ command="$(ps -axH -o command=)"
+ elif [[ "$OSTYPE" == (freebsd|openbsd|darwin)* ]]; then
+ command="$(ps -ax -o command=)"
+ else
+ command="$(ps -A o cmd=)"
+ fi
+ _wanted pname expl $ispat'process command line' compadd ${(u)${(f)${command}}}
else
- _wanted pname expl $ispat'process name' compadd ${(u)${(f)"$(ps -A co cmd=)"}}
+ if [[ "$OSTYPE" == freebsd* ]] && (( ${+opt_args[-S]} )); then
+ command="$(ps -axcH -o command=)"
+ elif [[ "$OSTYPE" == (freebsd|openbsd|darwin)* ]]; then
+ command="$(ps -axc -o command=)"
+ else
+ command="$(ps -A co cmd=)"
+ fi
+ _wanted pname expl $ispat'process name' compadd ${(u)${(f)${command}}}
fi
;;
--
1.9.0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author