zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Completion for chrt and ionice
@ 2008-09-21 13:59 Jörg Sommer
  2008-09-22 16:53 ` Jörg Sommer
  0 siblings, 1 reply; 7+ messages in thread
From: Jörg Sommer @ 2008-09-21 13:59 UTC (permalink / raw)
  To: zsh-workers

Hi,

commit 14b01890163625d1aa41610beb46e00155090308
Author: Jörg Sommer <joerg@alea.gnuu.de>
Date:   Sun Sep 21 15:51:36 2008 +0200

    Completion for the Linux command ionice
    
    The command ionice is used on Linux to get or set the IO scheduling
    attributes of a process.

diff --git a/Completion/Linux/Command/_ionice b/Completion/Linux/Command/_ionice
new file mode 100644
index 0000000..e3b64aa
--- /dev/null
+++ b/Completion/Linux/Command/_ionice
@@ -0,0 +1,23 @@
+#compdef ionice
+
+local context state line
+typeset -A opt_args
+
+_arguments \
+  '(* -)-h[display usage information]' \
+  '-p[interpret args as process ID]' \
+  '-c[scheduling class]:class:(( 1\:realtime 2\:best-effort 3\:idle ))' \
+  '-n[scheduling class priority]:class-pririty:((
+    0\:high\ priority
+    {1..6}\:
+    7\:low\ priority
+  ))' \
+  '*::command or pid:->cmd_or_pid' \
+  && return 0
+
+if (( $+opt_args[-p] ))
+then
+    _pids
+else
+    _normal
+fi

commit fc7231b2bd501b2a3dc753567c2ae8c4deddf9e7
Author: Jörg Sommer <joerg@alea.gnuu.de>
Date:   Sun Sep 21 15:50:10 2008 +0200

    Completion for the Linux command chrt
    
    The command chrt is used on Linux to get or set the real‐time attributes
    of a process.

diff --git a/Completion/Linux/Command/_chrt b/Completion/Linux/Command/_chrt
new file mode 100644
index 0000000..f82ec8b
--- /dev/null
+++ b/Completion/Linux/Command/_chrt
@@ -0,0 +1,61 @@
+#compdef chrt
+
+local context state line
+typeset -A opt_args
+
+_arguments \
+  '(* -)'{-h,--help}'[display usage information]' \
+  '(* -)'{-V,--version}'[output version information]' \
+  {-v,--verbose}'[display status information]' \
+  {-p,--pid}'[interpret args as process ID]' \
+  '(-b --batch -f --fifo -o --other -r --rr)'{-b,--batch}'[set scheduling policy to SCHED_BATCH]' \
+  '(-b --batch -f --fifo -o --other -r --rr)'{-f,--fifo}'[set scheduling policy to SCHED_FIFO]' \
+  '(-b --batch -f --fifo -o --other -r --rr)'{-o,--other}'[set policy scheduling policy to SCHED_OTHER]' \
+  '(-b --batch -f --fifo -o --other -r --rr)'{-r,--rr}'[set scheduling policy to SCHED_RR]' \
+  '(* -)'{-m,--max}'[show minimum and maximum valid priorities, then exit]' \
+  '*::command or priority:->cmd_or_prio' \
+  && return 0
+
+_chrt_priority()
+{
+    local ty
+    if (( $+opt_args[-b] || $+opt_args[--batch] ))
+    then
+        ty=BATCH
+    elif (( $+opt_args[-f] || $+opt_args[--fifo] ))
+    then
+        ty=FIFO
+    elif (( $+opt_args[-o] || $+opt_args[--other] ))
+    then
+        ty=OTHER
+    else
+        ty=RR
+    fi
+    local range
+    range=${${"$(_call_program priorities chrt --max)"#*SCHED_$ty*: }%$'\n'*}
+    if [[ $range = 0/0 ]]
+    then
+        compadd 0
+    else
+        _message -e priority "priority in the range $range"
+    fi
+}
+
+if (( $+opt_args[-p] || $+opt_args[--pid] ))
+then
+    if [[ $CURRENT -eq 1 ]]
+    then
+        _alternative \
+          'priority:priority:_chrt_priority' \
+          'processes:process IDs:_pids'
+    else
+        _pids
+    fi
+elif [[ $CURRENT -eq 1 ]]
+then
+    _chrt_priority
+else
+    shift words
+    (( CURRENT-- ))
+    _normal
+fi

Bye, Jörg.
-- 
Macht besitzen und nicht ausüben ist wahre Größe.
                                                   (Friedl Beutelrock)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Completion for chrt and ionice
  2008-09-21 13:59 [PATCH] Completion for chrt and ionice Jörg Sommer
@ 2008-09-22 16:53 ` Jörg Sommer
  2008-09-23  5:28   ` Clint Adams
  2008-10-03  1:11   ` Jörg Sommer
  0 siblings, 2 replies; 7+ messages in thread
From: Jörg Sommer @ 2008-09-22 16:53 UTC (permalink / raw)
  To: zsh-workers

Hi,

Jörg Sommer <joerg@alea.gnuu.de> wrote:
> commit 14b01890163625d1aa41610beb46e00155090308
> Author: Jörg Sommer <joerg@alea.gnuu.de>
> Date:   Sun Sep 21 15:51:36 2008 +0200
>
>     Completion for the Linux command ionice
>     
>     The command ionice is used on Linux to get or set the IO scheduling
>     attributes of a process.

This completion is not correct. Here are patches for it:

commit 0488523c0581a74a321d8c1e1852bc0aa58a2003
Author: Jörg Sommer <joerg@alea.gnuu.de>
Date:   Mon Sep 22 16:50:03 2008 +0200

    Reverse the order of unnamed priorities
    
    The completion was printed in reverse order. So add the entries in
    descending order to get the ascending ording in the help message.

diff --git a/Completion/Linux/Command/_ionice b/Completion/Linux/Command/_ionice
index e3b64aa..fd49dcd 100644
--- a/Completion/Linux/Command/_ionice
+++ b/Completion/Linux/Command/_ionice
@@ -9,7 +9,7 @@ _arguments \
   '-c[scheduling class]:class:(( 1\:realtime 2\:best-effort 3\:idle ))' \
   '-n[scheduling class priority]:class-pririty:((
     0\:high\ priority
-    {1..6}\:
+    {6..1}\:
     7\:low\ priority
   ))' \
   '*::command or pid:->cmd_or_prio' \

commit e2da3b57bfa4145811aa3b3921edb329b7bef1f7
Author: Jörg Sommer <joerg@alea.gnuu.de>
Date:   Mon Sep 22 16:54:28 2008 +0200

    The pid for -p must follow the option
    
    The process ID is the mandatory argument of the -p option.

diff --git a/Completion/Linux/Command/_ionice b/Completion/Linux/Command/_ionice
index fd49dcd..b7cd21b 100644
--- a/Completion/Linux/Command/_ionice
+++ b/Completion/Linux/Command/_ionice
@@ -1,23 +1,12 @@
 #compdef ionice
 
-local context state line
-typeset -A opt_args
-
 _arguments \
   '(* -)-h[display usage information]' \
-  '-p[interpret args as process ID]' \
+  '(*)-p[interpret args as process ID]:pid:_pids' \
   '-c[scheduling class]:class:(( 1\:realtime 2\:best-effort 3\:idle ))' \
   '-n[scheduling class priority]:class-pririty:((
     0\:high\ priority
     {6..1}\:
     7\:low\ priority
   ))' \
-  '*::command or pid:->cmd_or_prio' \
-  && return 0
-
-if (( $+opt_args[-p] ))
-then
-    _pids
-else
-    _normal
-fi
+  '*::command:_normal'

Bye, Jörg.
-- 
“…anytime you install something new on the Windows platform, you risk
spending the next five or six hours trying to figure out what happened”
            (Robert Roblin, Adobe)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Completion for chrt and ionice
  2008-09-22 16:53 ` Jörg Sommer
@ 2008-09-23  5:28   ` Clint Adams
  2008-10-03  1:11   ` Jörg Sommer
  1 sibling, 0 replies; 7+ messages in thread
From: Clint Adams @ 2008-09-23  5:28 UTC (permalink / raw)
  To: zsh-workers

On Mon, Sep 22, 2008 at 04:53:59PM +0000, Jörg Sommer wrote:
> This completion is not correct. Here are patches for it:

plus one spelling fix.

Index: Completion/Linux/Command/_ionice
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Linux/Command/_ionice,v
retrieving revision 1.2
diff -u -r1.2 _ionice
--- Completion/Linux/Command/_ionice	23 Sep 2008 05:26:54 -0000	1.2
+++ Completion/Linux/Command/_ionice	23 Sep 2008 05:27:18 -0000
@@ -4,7 +4,7 @@
   '(* -)-h[display usage information]' \
   '(*)-p[interpret args as process ID]' \
   '-c[scheduling class]:class:(( 1\:realtime 2\:best-effort 3\:idle ))' \
-  '-n[scheduling class priority]:class-pririty:((
+  '-n[scheduling class priority]:class-priority:((
     0\:high\ priority
     {6..1}\:
     7\:low\ priority


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Completion for chrt and ionice
  2008-09-22 16:53 ` Jörg Sommer
  2008-09-23  5:28   ` Clint Adams
@ 2008-10-03  1:11   ` Jörg Sommer
  2008-10-03  2:32     ` Clint Adams
  1 sibling, 1 reply; 7+ messages in thread
From: Jörg Sommer @ 2008-10-03  1:11 UTC (permalink / raw)
  To: zsh-workers

Hallo,

Jörg Sommer <joerg@alea.gnuu.de> wrote:
> commit e2da3b57bfa4145811aa3b3921edb329b7bef1f7
> Author: Jörg Sommer <joerg@alea.gnuu.de>
> Date:   Mon Sep 22 16:54:28 2008 +0200
>
>     The pid for -p must follow the option
>     
>     The process ID is the mandatory argument of the -p option.
>
> diff --git a/Completion/Linux/Command/_ionice b/Completion/Linux/Command/_ionice
> index fd49dcd..b7cd21b 100644
> --- a/Completion/Linux/Command/_ionice
> +++ b/Completion/Linux/Command/_ionice
> @@ -1,23 +1,12 @@
>  #compdef ionice
>  
> -local context state line
> -typeset -A opt_args
> -
>  _arguments \
>    '(* -)-h[display usage information]' \
> -  '-p[interpret args as process ID]' \
> +  '(*)-p[interpret args as process ID]:pid:_pids' \
                                         ^^^^^^^^^^
Why this is missing in 25717?

>    '-c[scheduling class]:class:(( 1\:realtime 2\:best-effort 3\:idle ))' \
>    '-n[scheduling class priority]:class-pririty:((
>      0\:high\ priority
>      {6..1}\:
>      7\:low\ priority
>    ))' \
> -  '*::command or pid:->cmd_or_prio' \
> -  && return 0
> -
> -if (( $+opt_args[-p] ))
> -then
> -    _pids
> -else
> -    _normal
> -fi
> +  '*::command:_normal'

Bye, Jörg.
-- 
Computer Science is no more about Computers than astronomy is about
telescopes.
            (Edsger Wybe Dijkstra)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Completion for chrt and ionice
  2008-10-03  1:11   ` Jörg Sommer
@ 2008-10-03  2:32     ` Clint Adams
  2008-10-03 16:07       ` Jörg Sommer
  0 siblings, 1 reply; 7+ messages in thread
From: Clint Adams @ 2008-10-03  2:32 UTC (permalink / raw)
  To: Jörg Sommer; +Cc: zsh-workers

On Fri, Oct 03, 2008 at 01:11:03AM +0000, Jörg Sommer wrote:
> > +  '(*)-p[interpret args as process ID]:pid:_pids' \
>                                          ^^^^^^^^^^
> Why this is missing in 25717?

Because I screwed up the patch application.  Twice.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Completion for chrt and ionice
  2008-10-03  2:32     ` Clint Adams
@ 2008-10-03 16:07       ` Jörg Sommer
  2008-10-04 18:15         ` Clint Adams
  0 siblings, 1 reply; 7+ messages in thread
From: Jörg Sommer @ 2008-10-03 16:07 UTC (permalink / raw)
  To: zsh-workers

Hello Clint,

Clint Adams <clint@zsh.org> wrote:
> On Fri, Oct 03, 2008 at 01:11:03AM +0000, Jörg Sommer wrote:
>> > +  '(*)-p[interpret args as process ID]:pid:_pids' \
>>                                          ^^^^^^^^^^
>> Why this is missing in 25717?
>
> Because I screwed up the patch application.  Twice.

In which form do you prever patches? One per mail or somewhere on the net
and an URL?

Regards, Jörg.
-- 
> Definiere ‚Demokratie‘ …
… eine Mehrheit beweist einer Minderheit, dass Widerstand zwecklos ist.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Completion for chrt and ionice
  2008-10-03 16:07       ` Jörg Sommer
@ 2008-10-04 18:15         ` Clint Adams
  0 siblings, 0 replies; 7+ messages in thread
From: Clint Adams @ 2008-10-04 18:15 UTC (permalink / raw)
  To: Jörg Sommer; +Cc: zsh-workers

On Fri, Oct 03, 2008 at 04:07:28PM +0000, Jörg Sommer wrote:
> In which form do you prever patches? One per mail or somewhere on the net
> and an URL?

Probably best to follow Etc/zsh-development-guide regardless of my
preferences.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-10-04 18:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-21 13:59 [PATCH] Completion for chrt and ionice Jörg Sommer
2008-09-22 16:53 ` Jörg Sommer
2008-09-23  5:28   ` Clint Adams
2008-10-03  1:11   ` Jörg Sommer
2008-10-03  2:32     ` Clint Adams
2008-10-03 16:07       ` Jörg Sommer
2008-10-04 18:15         ` Clint Adams

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).