]> git.ipfire.org Git - thirdparty/util-linux.git/blame - bash-completion/taskset
su: use lib/pty-session.c code for --pty
[thirdparty/util-linux.git] / bash-completion / taskset
CommitLineData
18b0017a
SK
1_taskset_module()
2{
3 local cur prev OPTS
4 COMPREPLY=()
5 cur="${COMP_WORDS[COMP_CWORD]}"
6 prev="${COMP_WORDS[COMP_CWORD-1]}"
7 case $prev in
8 '-c'|'--cpu-list')
b5b80e5a
BE
9 local prefix realcur CPULIST_ALL CPULIST
10 realcur="${cur##*,}"
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
c6f0bdfe 15 CPULIST="$WORD ${CPULIST:-""}"
b5b80e5a
BE
16 fi
17 done
18 compopt -o nospace
19 COMPREPLY=( $(compgen -P "$prefix" -W "$CPULIST" -S ',' -- $realcur) )
18b0017a
SK
20 return 0
21 ;;
22 '-p'|'--pid')
23 local PIDS
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
27 # affinity.
75c5f4a5 28 PIDS=$(cd /proc && echo [0-9]*)
18b0017a
SK
29 COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
30 return 0
31 ;;
d4f9b8d7
VS
32 '-h'|'--help'|'-V'|'--version')
33 return 0
34 ;;
18b0017a
SK
35 esac
36 case $cur in
37 -*)
0d5b9b8a 38 OPTS="--all-tasks --pid --cpu-list --help --version"
18b0017a
SK
39 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
40 return 0
41 ;;
42 esac
43 compopt -o bashdefault
44 COMPREPLY=( $(compgen -c -- $cur) )
45 return 0
46}
47complete -F _taskset_module taskset