summaryrefslogtreecommitdiffstats
path: root/bash-completion/taskset
diff options
context:
space:
mode:
Diffstat (limited to 'bash-completion/taskset')
-rw-r--r--bash-completion/taskset16
1 files changed, 11 insertions, 5 deletions
diff --git a/bash-completion/taskset b/bash-completion/taskset
index dd1ef1f69..8e62a3b67 100644
--- a/bash-completion/taskset
+++ b/bash-completion/taskset
@@ -6,11 +6,17 @@ _taskset_module()
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-c'|'--cpu-list')
- local CPULIST
- # FIXME: will propose only binding to a cpu.
- # Maybe this should add comma, and continue?
- CPULIST=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/online)
- COMPREPLY=( $(compgen -W "$(eval echo $CPULIST)" -- $cur) )
+ local prefix realcur CPULIST_ALL CPULIST
+ realcur="${cur##*,}"
+ prefix="${cur%$realcur}"
+ CPULIST_ALL=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/online)
+ for WORD in $(eval echo $CPULIST_ALL); do
+ if ! [[ $prefix == *"$WORD"* ]]; then
+ CPULIST="$WORD $CPULIST"
+ fi
+ done
+ compopt -o nospace
+ COMPREPLY=( $(compgen -P "$prefix" -W "$CPULIST" -S ',' -- $realcur) )
return 0
;;
'-p'|'--pid')