]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
bash-completion: update chrt completion
authorSami Kerola <kerolasa@iki.fi>
Sun, 3 Apr 2016 08:35:28 +0000 (09:35 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 4 Apr 2016 08:26:03 +0000 (10:26 +0200)
Add couple missing options, and make the completion overall work better.

That said completion is still incomplete, pardon the pun.  After user has
specified policy then giving a hint what priority needs to be specified is
theoretically possible, but such hint is not given.  There does not seem to
be easy way to know when user wants stops specifying options and move to
defining priority in: chrt [options] [prio] [command|pid].

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
bash-completion/chrt

index 388d2981956cc3cb709c059db79648ec5c72eb02..ce0b915b337d7a3ee71e84856aefba4c42340bd8 100644 (file)
@@ -8,31 +8,45 @@ _chrt_module()
                '-h'|'--help'|'-V'|'--version')
                        return 0
                        ;;
+               '-T'|'--sched-runtime'|'-P'|'--sched-period'|'-D'|'--sched-deadline')
+                       COMPREPLY=( $(compgen -W "nanoseconds" -- $cur) )
+                       return 0
+                       ;;
        esac
-       # FIXME: -p is ambiguous, it takes either pid or priority as an
-       # argument depending on whether user wanted to get or set the
-       # values.  Perhaps the command interface should be reconsidered.
        case $cur in
                -*)
-                       OPTS="--batch
-                               --fifo
-                               --idle
-                               --other
-                               --rr
-                               --reset-on-fork
+                       OPTS="
                                --all-tasks
+                               --batch
+                               --deadline
+                               --fifo
                                --help
+                               --idle
                                --max
+                               --other
                                --pid
+                               --reset-on-fork
+                               --rr
+                               --sched-deadline
+                               --sched-period
+                               --sched-runtime
                                --verbose
-                               --version"
+                               --version
+                       "
                        COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
                        return 0
                        ;;
        esac
-       local PIDS
-       PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
-       COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
+       local i
+       for i in ${COMP_WORDS[*]}; do
+               case $i in
+               '-p'|'--pid')
+                       COMPREPLY=( $(compgen -W "$(cd /proc && echo [0-9]*)" -- $cur) )
+                       return 0
+                       ;;
+               esac
+       done
+       COMPREPLY=( $(compgen -c -- $cur) )
        return 0
 }
 complete -F _chrt_module chrt