Debian Codegraph @

bash-completion/losetup

raw
1 _losetup_module()
2 {
3 local cur prev OPTS ARG
4 COMPREPLY=()
5 cur="${COMP_WORDS[COMP_CWORD]}"
6 prev="${COMP_WORDS[COMP_CWORD-1]}"
7 case $prev in
8 '-d'|'--detach')
9 ARG="$($1 --output NAME | command awk '{if (1 < NR) {print}}')"
10 COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
11 return 0
12 ;;
13 '-j'|'--associated')
14 ARG="$($1 --output BACK-FILE | command awk '{if (1 < NR) {print}}')"
15 COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
16 return 0
17 ;;
18 '-c'|'--set-capacity'|'--remove')
19 ARG="$(for I in /dev/loop[0-9]*; do if [ -e $I ]; then echo $I; fi; done)"
20 COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
21 return 0
22 ;;
23 '-o'|'--offset'|'--sizelimit')
24 COMPREPLY=( $(compgen -W "number" -- $cur) )
25 return 0
26 ;;
27 '-O'|'--output')
28 local prefix realcur OUTPUT_ALL OUTPUT
29 realcur="${cur##*,}"
30 prefix="${cur%$realcur}"
31 OUTPUT_ALL="NAME AUTOCLEAR BACK-FILE BACK-INO
32 BACK-MAJ:MIN MAJ:MIN OFFSET PARTSCAN RO
33 SIZELIMIT DIO"
34 for WORD in $OUTPUT_ALL; do
35 if ! [[ $prefix == *"$WORD"* ]]; then
36 OUTPUT="$WORD ${OUTPUT:-""}"
37 fi
38 done
39 compopt -o nospace
40 COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) )
41 return 0
42 ;;
43 '-h'|'--help'|'-V'|'--version')
44 return 0
45 ;;
46 esac
47 case $cur in
48 -*)
49 OPTS="--all
50 --detach
51 --detach-all
52 --find
53 --set-capacity
54 --associated
55 --nooverlap
56 --offset
57 --sizelimit
58 --partscan
59 --read-only
60 --remove
61 --show
62 --direct-io
63 --loop-ref
64 --sector-size
65 --json
66 --list
67 --noheadings
68 --output
69 --output-all
70 --raw
71 --help
72 --version"
73 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
74 return 0
75 ;;
76 esac
77 local IFS=$'\n'
78 compopt -o filenames
79 COMPREPLY=( $(compgen -f -- $cur) )
80 return 0
81 }
82 complete -F _losetup_module losetup