* Re: Suggestion for _killall
@ 1999-11-19 8:55 Sven Wischnowsky
0 siblings, 0 replies; 4+ messages in thread
From: Sven Wischnowsky @ 1999-11-19 8:55 UTC (permalink / raw)
To: zsh-workers
Falk Hueffner wrote:
> Hi,
>
> I suggest this patch for _killall to also complete command names:
I suggest that we use the patch below instead -- it uses descriptions
and tags. This also (finally) adds the function `_signals' to complete
signal names and makes it be used everywhere. This also uses/tests the
prefix-needed and prefix-hidden styles.
Bye
Sven
diff -u -r oldcompletion/Builtins/_kill Completion/Builtins/_kill
--- oldcompletion/Builtins/_kill Thu Nov 18 08:51:26 1999
+++ Completion/Builtins/_kill Fri Nov 19 09:48:58 1999
@@ -1,10 +1,6 @@
#compdef kill
-local list expl
-
-if compset -P 1 -; then
- _wanted -C - expl signal &&
- compadd "$expl[@]" $signals[1,-3]
-else
- _alternative -C argument 'jobs:: _jobs' 'processes:: _pids'
-fi
+_alternative \
+ 'signals:: _signals -p' \
+ 'jobs:: _jobs' \
+ 'processes:: _pids'
diff -u -r oldcompletion/Builtins/_signals Completion/Builtins/_signals
--- oldcompletion/Builtins/_signals Fri Nov 19 09:50:30 1999
+++ Completion/Builtins/_signals Fri Nov 19 09:53:49 1999
@@ -0,0 +1,36 @@
+#autoload
+
+# Options (only in separate words):
+#
+# -a use all signals (even the pseudo-signals)
+# -p needs a `-' prefix
+#
+# A `-' or `--' as the first argument is ignored.
+
+local expl last=-3 minus
+
+while [[ "$1" = -[ap] ]]; do
+ if [[ "$1" = -a ]]; then
+ last=-1
+ else
+ minus=-
+ fi
+ shift
+done
+
+[[ "$1" = -(|-) ]] && shift
+
+if _wanted signals expl signal &&
+ { [[ -z "$minus" ]] || ! _style signals prefix-needed ||
+ [[ "$PREFIX" = -* ]] } ; then
+ local disp tmp
+
+ if _style signals prefix-hidden; then
+ tmp=( "${(@)signals[1,last]}" )
+ disp=(-d tmp)
+ else
+ disp=()
+ fi
+ compadd "$@" "$expl[@]" "$disp[@]" -M 'm:{a-z}=${A-Z}' - \
+ "${minus}${(@)^signals[1,last]}"
+fi
diff -u -r oldcompletion/Builtins/_trap Completion/Builtins/_trap
--- oldcompletion/Builtins/_trap Thu Nov 18 08:51:27 1999
+++ Completion/Builtins/_trap Fri Nov 19 09:50:16 1999
@@ -6,5 +6,5 @@
compset -q
_normal
else
- _wanted signals expl signal && compadd "$expl[@]" - "$signals[@]"
+ _signals -a
fi
diff -u -r oldcompletion/User/_killall Completion/User/_killall
--- oldcompletion/User/_killall Thu Nov 18 08:51:35 1999
+++ Completion/User/_killall Fri Nov 19 09:47:57 1999
@@ -1,4 +1,5 @@
#compdef killall
-compset -P 1 - && _wanted -C - signals expl signal &&
- compadd "$expl[@]" $signals[1,-3]
+_alternative \
+ 'signals:: _signals -p' \
+ 'processes:process:{ compadd "$expl[@]" ${$(ps ho comm 2> /dev/null):#(ps|COMMAND)} }'
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Suggestion for _killall
@ 1999-11-19 9:21 Sven Wischnowsky
0 siblings, 0 replies; 4+ messages in thread
From: Sven Wischnowsky @ 1999-11-19 9:21 UTC (permalink / raw)
To: zsh-workers
Alexandre Duret-Lutz wrote:
> >>> "FH" == Falk Hueffner <falk.hueffner@student.uni-tuebingen.de> writes:
>
> [...]
>
> FH> Unfortunately, ps behaves different on each platform, so I don't know
> FH> if this is really portable.
>
> It isn't. Perhaps it could be done the same way as _kill?
> One other issue is that killall also behaves differently :
>
> - On Debian (and probably most Linux distribution) it kill
> process by names;
>
> - On Solaris, Digital Unix, RISC/os and maybe others, it kills
> *all* actives process and thus completing with process name is
> inappropriate.
Uh, oh...
> Maybe there could be two _killall in Zsh ? Let's say one in
> Completion/User/_killall and one in Completion/Linux/_killall. Then
> ./configure and Makefile would be hacked to install Linux/* only on
> Linux system and in such a way that Linux/* functions would overwrite
> previously installed User/* completions. Look quite ugly :(
I thought we had agreed that for this kind of stuff the function
itself does the test. at least _mount has been doing it for some time
now. And now _killall does the same. Dunno if the test is good enough,
though.
On top of my previous one, obviously.
Bye
Sven
diff -u oldcompletion/User/_killall Completion/User/_killall
--- oldcompletion/User/_killall Fri Nov 19 09:56:05 1999
+++ Completion/User/_killall Fri Nov 19 10:18:47 1999
@@ -1,5 +1,9 @@
#compdef killall
-_alternative \
- 'signals:: _signals -p' \
- 'processes:process:{ compadd "$expl[@]" ${$(ps ho comm 2> /dev/null):#(ps|COMMAND)} }'
+if [[ "$OSTYPE" = linux* ]]; then
+ _alternative \
+ 'signals:: _signals -p' \
+ 'processes:process:{ compadd "$expl[@]" ${$(ps ho comm 2> /dev/null):#(ps|COMMAND)} }'
+else
+ _signals -p
+fi
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* Suggestion for _killall
@ 1999-11-18 21:24 Falk Hueffner
1999-11-19 10:10 ` Alexandre Duret-Lutz
0 siblings, 1 reply; 4+ messages in thread
From: Falk Hueffner @ 1999-11-18 21:24 UTC (permalink / raw)
To: zsh-workers
Hi,
I suggest this patch for _killall to also complete command names:
--- _killall~ Sun Nov 7 23:43:03 1999
+++ _killall Thu Nov 18 22:16:05 1999
@@ -4,3 +4,5 @@
_description expl signal
compadd "$expl[@]" $signals[1,-3]
fi
+
+compadd ${$(ps ho comm 2> /dev/null)#ps}
Unfortunately, ps behaves different on each platform, so I don't know
if this is really portable.
Falk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Suggestion for _killall
1999-11-18 21:24 Falk Hueffner
@ 1999-11-19 10:10 ` Alexandre Duret-Lutz
0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Duret-Lutz @ 1999-11-19 10:10 UTC (permalink / raw)
To: zsh-workers; +Cc: Falk Hueffner
>>> "FH" == Falk Hueffner <falk.hueffner@student.uni-tuebingen.de> writes:
[...]
FH> Unfortunately, ps behaves different on each platform, so I don't know
FH> if this is really portable.
It isn't. Perhaps it could be done the same way as _kill?
One other issue is that killall also behaves differently :
- On Debian (and probably most Linux distribution) it kill
process by names;
- On Solaris, Digital Unix, RISC/os and maybe others, it kills
*all* actives process and thus completing with process name is
inappropriate.
Maybe there could be two _killall in Zsh ? Let's say one in
Completion/User/_killall and one in Completion/Linux/_killall. Then
./configure and Makefile would be hacked to install Linux/* only on
Linux system and in such a way that Linux/* functions would overwrite
previously installed User/* completions. Look quite ugly :(
--
Alexandre Duret-Lutz
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1999-11-19 9:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-19 8:55 Suggestion for _killall Sven Wischnowsky
-- strict thread matches above, loose matches on Subject: below --
1999-11-19 9:21 Sven Wischnowsky
1999-11-18 21:24 Falk Hueffner
1999-11-19 10:10 ` Alexandre Duret-Lutz
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).