From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27193 invoked by alias); 28 Jun 2018 08:23:35 -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: List-Unsubscribe: X-Seq: 43108 Received: (qmail 19557 invoked by uid 1010); 28 Jun 2018 08:23:34 -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.3):SA:0(-2.6/5.0):. Processed in 0.573883 secs); 28 Jun 2018 08:23:34 -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, 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] rewrite _killall Message-Id: Date: Thu, 28 Jun 2018 16:39:35 +0900 To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.3273) X-Biglobe-Spnum: 51982 _killall has many options which need be completed. The previous patch to _ttys is required. diff --git a/Completion/Unix/Command/_killall = b/Completion/Unix/Command/_killall index 375b1bf74..989772c5d 100644 --- a/Completion/Unix/Command/_killall +++ b/Completion/Unix/Command/_killall @@ -1,9 +1,77 @@ #compdef killall killall5 =20 -if [[ $service =3D killall && "$OSTYPE" =3D (linux*|*bsd*|darwin*) ]]; = then - _alternative \ - 'signals:: _signals -p' \ - 'processes-names:process:{ compadd "$expl[@]" = ${${${${(f)"$(_call_program processes-names ps = ${${EUID/(#s)0(#e)/xa}//[0-9]#/}ho command 2> = /dev/null)"//[][\(\)]/}:#(ps|COMMAND|-*)}%%\ *}:t} }' -else +if [[ $service =3D killall5 || $OSTYPE !=3D = (linux|*bsd|dragonfly|darwin)* ]]; then _signals -p + return +fi + +typeset -a opts args +[[ $EUID =3D 0 || $_comp_priv_prefix[1] =3D sudo ]] && opts=3D( -a ) + +if _pick_variant psmisc=3DPSmisc unix --version; then + + local curcontext=3D$curcontext state state_descr line ret=3D1 + typeset -A opt_args + args=3D( + '(-e --exact)'{-e,--exact}'[require exact match for names longer = than 15 chars]' + '(-I --ignore-case)'{-I,--ignore-case}'[do case insensitive process = name match]' + '(-g --process-group)'{-g,--process-group}'[kill the process group = to which the process blongs]' + '(-i --interactive)'{-i,--interactive}'[interactively ask for = confirmation before killing]' + '(- : *)'{-l,--list}'[list all known signal names]' + '(-n --ns)'{-n,--ns}'[match against the PID namespace of the given = PID]:pid: _pids' + '(-o --older-than)'{-o,--older-than}'[match only processes older = than the specified time]:time:->time' + '(-q --quiet)'{-q,--quiet}'[do not complain if no processes were = killed]' + '(-r --regexp)'{-r,--regexp}'[interpret process name as extended = regular expression]' + '(-s --signal)'{-s,--signal}'[send the speified = signal]:signal:_signals' + '(-u --user)'{-u,--user}'[kill only processes owned by specified = user]: : _users' + '(-v --verbose)'{-v,--verbose}'[report if the signal was = successfully sent]' + '(-w --wait)'{-w,--wait}'[wait for all killed processes to die]' + '(- : *)'{-V,--version}'[display version information]' + '(-y --younger-than)'{-y,--younger-than}'[match only processes = younger than the specified time]:time:->time' + "1: : _alternative 'signals: :_signals -p' 'processes-names: = :_process_names $opts'" + "*: :_process_names $opts" + ) + [[ $CURRENT =3D 2 || ( $CURRENT =3D 3 && $words[2] =3D (-Z|--context) = ) ]] && \ + args+=3D( '(-Z --context)'{-Z,--context}'[specify SELinux security = context]:regex pattern: ' ) + + _arguments -s -S -C : $args && ret=3D0 + + case $state in + (time) + local -a units=3D( 's:seconds' 'm:minuts' 'h:hours' 'd:days' + 'w:weeks' 'M:months' 'y:years' ) + if compset -P '[0-9]##(|.[0-9]#)'; then + _alternative 'float-number:: _message "float number"' \ + 'unit:: _describe unit units' && ret=3D0 + else + _message 'float number and unit' && ret=3D0 + fi + ;; + esac + + return ret + +else # bsd and darwin + + if [[ $OSTYPE =3D=3D (freebsd|dragonfly)* ]]; then + args=3D( '-j[kill processes in specified jail]: :_jails -0' ) + opts+=3D( -t ) # long process names must be truncated + fi + args+=3D( + '-v[be more verbose about what will be done]' + '-e[use effective user ID for -u option]' + '(- : *)-help[give a help on command usage and exit]' + '(- : *)-l[list names of available signals and exit]' + '-m[interprit specified name as a regular expression]' + '-s[show only what will be done, but do notsend any signal]' + '-d[print info about processes matched, but do not send any = signal]' + '-u[limit to processes belonging to specified user]: :_users' + '-t[limit to processes running on specified tty]: :_ttys -od' + "-c[with -u or -t, limit to processes matching specified name]: = :_process_names $opts" + '-z[do not skip zombies]' + "1: : _alternative 'signals::_signals -p' = 'processes-names::_process_names $opts'" + "*: :_process_names $opts" + ) + _arguments -s -S : $args + fi