bash-completion: update chrt completion

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>
This commit is contained in:
Sami Kerola 2016-04-03 09:35:28 +01:00 committed by Karel Zak
parent b3a5067148
commit 0fc63d38f3
1 changed files with 27 additions and 13 deletions

View 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