5 cur="${COMP_WORDS[COMP_CWORD]}"
6 prev="${COMP_WORDS[COMP_CWORD-1]}"
9 local prefix realcur CPULIST_ALL CPULIST
11 prefix="${cur%$realcur}"
12 CPULIST_ALL=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/online)
13 for WORD in $(eval echo $CPULIST_ALL); do
14 if ! [[ $prefix == *"$WORD"* ]]; then
15 CPULIST="$WORD $CPULIST"
19 COMPREPLY=( $(compgen -P "$prefix" -W "$CPULIST" -S ',' -- $realcur) )
24 # FIXME: the pid argument is ambiguous. When
25 # setting an affinity the optarg has to be cpu
26 # mask. The following is good only for getting
28 PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
29 COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
32 '-h'|'--help'|'-V'|'--version')
38 OPTS="--all-tasks --pid --cpu-list --help --version"
39 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
43 compopt -o bashdefault
44 COMPREPLY=( $(compgen -c -- $cur) )
47 complete -F _taskset_module taskset