From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10740 invoked by alias); 1 Sep 2017 16:49:55 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41628 Received: (qmail 9956 invoked by uid 1010); 1 Sep 2017 16:49:55 -0000 X-Qmail-Scanner-Diagnostics: from rcpt-mqugw.biglobe.ne.jp by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(133.208.100.2):SA:0(-2.6/5.0):. Processed in 2.600359 secs); 01 Sep 2017 16:49:55 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD,SPF_PASS autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: takimoto-j@kba.biglobe.ne.jp X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Biglobe-Sender: From: "Jun T." Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [PATCH] update _ps (with question) Message-Id: <68D6FE10-4636-4582-AC2A-1FB0852EAC28@kba.biglobe.ne.jp> Date: Sat, 2 Sep 2017 01:03:55 +0900 To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.3273) X-Biglobe-Spnum: 62548 I tried to update _ps, but could not understand the last part: if [[ -z $pids ]]; then _pids && compstate[insert]=3D fi Why compstate[insert] need be reset here? If it is reset, then nothing is completed by 'ps ...' I've removed it in the patch below, but not sure it is the right thing to do. diff --git a/Completion/Unix/Command/_ps b/Completion/Unix/Command/_ps index 6f67f7933..80b02e501 100644 --- a/Completion/Unix/Command/_ps +++ b/Completion/Unix/Command/_ps @@ -11,7 +11,7 @@ _ps_props() { =20 case $OSTYPE in linux-gnu) opts=3D( ${${(f)"$(_call_program properties $words[1] = L)"}%% *} ) ;; - freebsd*) opts=3D( $(_call_program properties $words[1] L) ) ;; + *bsd*|dragonfly*|darwin*) opts=3D( $(_call_program properties = $words[1] L) ) ;; solaris*) opts=3D( ${=3D${(f)"$(_call_program properties $words[1] = - 2>&1)"}[-3,-1]} ) ;; esac =20 @@ -19,8 +19,8 @@ _ps_props() { } =20 local curcontext=3D"$curcontext" state line expl ret=3D1 -local short long -local -a args bsd bsdarg pids +local short long pids +local -a args bsd bsdarg local -A equivs =20 args=3D( @@ -46,26 +46,20 @@ args=3D( =20 bsd=3D( 'a[include processes belonging to other users]' - 'e[show environment after command]' '(j s u v X)l[output in long format]' '(l s u v X)j[output in job control format]' 'x[include processes with no controlling terminal]' - '(j l s v X)u[output in resource usage format]' '(j l s u X)v[output in virtual memory format]' '*w[wide output]' - 'H[show threads as if they were processes]' 'L[display all format specifiers]' 'S[include child process data with the parent]' 'T[select processes attached to current terminal]' - 'Z[show security data]' ) bsdarg=3D( '*p[select processes by ID]' '*t[select processes by attached terminal]' - '*U[select processes by effective user]' 'O[specify additional output fields]' 'o[specify output format]' - 'N[set namelist file for WCHAN display]' ) =20 case $OSTYPE in @@ -82,26 +76,73 @@ case $OSTYPE in '-Z[show zone with which process is associated]' ) ;; + linux-gnu|dragonfly*|freebsd*|netbsd*|openbsd*) + bsd+=3D( + 'e[show environment after command]' + '(j l s v X)u[output in resource usage format]' + ) + bsdarg+=3D( + 'N[set namelist file for WCHAN display]' + '*U[select processes by effective user]' + ) + ;| + linux-gnu|dragonfly*|freebsd*|openbsd*) + bsd+=3D( 'H[show threads as if they were processes]' ) + ;| darwin*|dragonfly*|freebsd*|netbsd*|openbsd*) bsd+=3D( 'A[select every process]' - 'C[ignore resident time for CPU percentage]' 'c[show just executable name for command]' 'h[repeat header lines, one per page of output]' '(r)m[sort by memory usage]' '(m)r[sort by CPU usage]' ) - bsdarg+=3D( - 'M[extract values from specified core]' - ) + ;| + darwin*|dragonfly*|freebsd*|netbsd*) + bsd+=3D( 'C[ignore resident time for CPU percentage]' ) + ;| + dragonfly*|freebsd*|netbsd*|openbsd*) + bsdarg+=3D( 'M[extract values from specified core]' ) ;| linux-gnu|netbsd*) bsdarg+=3D( 'k[specify sort order]' ) ;| - darwin*|freebsd*) bsdarg+=3D( 'G[select processes by real group]' ) = ;| + darwin*|freebsd*) + bsd+=3D( 'X[skip processes with no controlling terminal]' ) + bsdarg+=3D( '*G[select processes by real group]' ) + ;| + freebsd*|dragonfly*) + bsd+=3D( 'f[show command and environment for swapped out = processes]' ) ;| + netbsd*|openbsd*) + bsdarg+=3D( 'W[extract swap information from specified file]' ) + ;| + darwin*) + bsd+=3D( + 'd[select all processes except session leaders]' + 'E[show environment after command]' + 'f[full listing]' + 'M[show threads corresponding to each process]' + ) + bsdarg+=3D( + '*g[select processes by process group leader]' + '*U[select processes by real user]' + ) + if [[ $words[CURRENT] =3D -* ]]; then + bsd+=3D( 'e[select every process]' ) + bsdarg+=3D( 'u[select processes by user id]' ) + else + bsd+=3D( + 'e[show environment after command]' + '(j l v)u[output in resource usage format]' + ) + fi + ;; + dragonfly*) + bsd+=3D( 'R[subsort by parent/child chain]' ) + ;; freebsd*) bsd+=3D( 'd[show process hierarchy]' - 'f[show command and environment for swapped out processes]' '*J[select processes by jail ID]' + 'Z[show mac label]' ) ;; netbsd*) bsd+=3D( '(j l u v)s[output in thread format]' ) ;; @@ -109,7 +150,6 @@ case $OSTYPE in bsd+=3D( 'k[display information about kernel threads]' ) - bsdarg+=3D( 'W[extract swap information from the specified file]' ) ;; linux-gnu) args+=3D( @@ -127,7 +167,8 @@ case $OSTYPE in '--cumulative[include child process data with the parent]' '-n[set namelist file for WCHAN display]:file:_files' '(--no-headers = --no-heading)'{--no-headers,--no-heading}'[suppress headers]' - '--sort=3D[specify sort order]:order:_ps_props -s' + '(-q --quick-pid -a -A -d -e -N --deselect -C -p --pid --ppid -G = --Group -g --group -s --sid -t --tty -u --user -U --User --forest -H = --sort)'{-q+,--quick-pid=3D}'[select processes by ID (quick = mode)]:process ID:_sequence -s , _pids' + '--sort=3D[specify sort order]:order:_sequence -s , _ps_props -s' '-w[wide output]' '-m[show threads after processes]' '-T[show threads, with SPID column]' @@ -150,23 +191,33 @@ case $OSTYPE in '(j l u v X)s[output in signal format]' 'V[display version information]' '(j l s u v)X[output in register format]' + 'Z[show security data]' ) + bsdarg+=3D( 'q[select processes by ID (quick mode)]' ) ;; esac =20 -if (( CURRENT > 1 )) && [[ $OSTYPE !=3D solaris* || ( $OSTYPE =3D = linux-gnu && $words[CURRENT-1] !=3D -* ) ]]; then +if (( CURRENT > 1 )) && [[ $OSTYPE !=3D (solaris*|linux-gnu) || + ( $OSTYPE =3D linux-gnu && $words[CURRENT-1] !=3D -* ) = ]]; then case $words[CURRENT-1] in *k) - _wanted -C option-k-1 properties expl 'property' _sequence -s , = _ps_props -s - && return - ;; + local sopt + [[ $OSTYPE =3D linux-gnu ]] && sopt=3D'-s' + _wanted -C option-k-1 properties expl 'property' \ + _sequence -s , _ps_props $sopt - && return ;; + *g) [[ $OSTYPE =3D darwin* ]] && _wanted -C option-g-1 processes \ + expl 'process ID' _sequence -s , _pids && return ;; *G) _sequence -s , _groups && return ;; *J) _sequence _jails -0 && return ;; *[MNW]) _files && return ;; *t) _wanted -C option-t-1 ttys expl tty _sequence -s , _ttys -D && = return ;; - *p) _wanted -C option-p-1 processes expl 'process ID' _sequence -s = , _pids && return;; + *[pq]) _wanted -C "option-${words[CURRENT-1][-1]}-1" processes \ + expl 'process ID' _sequence -s , _pids && return ;; *U) _wanted -C option-U-1 users expl user _sequence -s , _users && = return ;; + *u) [[ $OSTYPE =3D darwin* && $words[CURRENT-1] =3D -* ]] && \ + _wanted -C option-u-1 users expl user _sequence -s , _users && = return ;; *[oO]) _wanted -C "option-${words[CURRENT-1][-1]}-1" properties \ expl 'property' _sequence -s , _ps_props - && return ;; esac @@ -182,6 +233,6 @@ fi _values -s '' -S ' ' 'options' $bsd && ret=3D0 _values -S ' ' 'options' $bsdarg && ret=3D0 if [[ -z $pids ]]; then - _pids && compstate[insert]=3D + _pids && ret=3D0 fi return ret