zsh-workers
 help / color / mirror / code / Atom feed
From: Jun T <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: [PATCH] fix '_ttys -o', and use it in _gdb and _pgrep
Date: Wed, 18 Jul 2018 18:09:29 +0900	[thread overview]
Message-ID: <89BD8CC6-ABBB-4D07-A2DA-F5A1F92D3E9C@kba.biglobe.ne.jp> (raw)

The option '-o' (open ttys only) I added recently to _ttys does not work
on Linux since 'ps -a' does not include session leaders.
We need to use 'ps -Ao tty=' and discard '?' or '??'.

_gdb and _pgrep are modified to use the option '-o'.


diff --git a/Completion/Unix/Command/_gdb b/Completion/Unix/Command/_gdb
index 510e6f1fa..18f797633 100644
--- a/Completion/Unix/Command/_gdb
+++ b/Completion/Unix/Command/_gdb
@@ -5,12 +5,12 @@ local cur="$words[CURRENT]" prev w list ret=1 expl
 [[ "$PREFIX" = --* ]] &&
     _arguments -- '*=(CORE|SYM)FILE:core file:_files' \
 		  '*=EXECFILE:executable:_files -g \*\(-\*\)' \
-		  '*=TTY:terminal device:_ttys' && return 0
+		  '*=TTY: :_ttys -o' && return 0
 
 if compset -P '-(cd|directory)='; then
   _files -/
 elif compset -P '-tty='; then
-  _wanted devices expl 'terminal device' _ttys
+  _ttys -o
 elif compset -P '-(exec|se)='; then
   _description files expl executable
   _files "$expl[@]" -g '*(-*)'
diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep
index b6020e5a9..86aef3462 100644
--- a/Completion/Unix/Command/_pgrep
+++ b/Completion/Unix/Command/_pgrep
@@ -40,7 +40,7 @@ arguments=(
   # _signals is OK here — we do it differently below
   '(ss)--signal=[specify signal to send to process]: :_signals -s'
   '-T+[match only on specified routing table]:routing table'
-  '(-t --terminal)'{-t+,--terminal=}'[match only on specified controlling terminals]:terminal device:_sequence _ttys -d'
+  '(-t --terminal)'{-t+,--terminal=}'[match only on specified controlling terminals]: :_sequence _ttys -do'
   '(-U --uid)'{-U+,--uid=}'[match only on specified real user IDs]: :_sequence _users'
   '(-u --euid)'{-u+,--euid=}'[match only on specified effective user IDs]: :_sequence _users'
   '(-v --inverse)'{-v,--inverse}'[negate matching]'
diff --git a/Completion/Unix/Type/_ttys b/Completion/Unix/Type/_ttys
index 7408395c8..3c40466cb 100644
--- a/Completion/Unix/Type/_ttys
+++ b/Completion/Unix/Type/_ttys
@@ -12,7 +12,7 @@ local stripdev optdev open
 zparseopts -D -K -E d=stripdev D=optdev o=open
 
 if [[ -n $open ]]; then
-  ttys=( ${(u)${(f)"$(_call_program open-ttys ps -ao tty=)"}%% *} )
+  ttys=( ${(u)${${(f)"$(_call_program open-ttys ps -Ao tty=)"}:#\?*}%% *} )
   _description open-ttys expl 'open tty'
 else
   ttys=( /dev/tty?*(N) /dev/pts/^ptmx(N) )





                 reply	other threads:[~2018-07-18  9:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=89BD8CC6-ABBB-4D07-A2DA-F5A1F92D3E9C@kba.biglobe.ne.jp \
    --to=takimoto-j@kba.biglobe.ne.jp \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).