]>
Commit | Line | Data |
---|---|---|
c6f8c3f5 SK |
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') | |
396a6d7d | 9 | ARG="$($1 --output NAME | awk '{if (1 < NR) {print}}')" |
c6f8c3f5 SK |
10 | COMPREPLY=( $(compgen -W "$ARG" -- $cur) ) |
11 | return 0 | |
12 | ;; | |
13 | '-j'|'--associated') | |
396a6d7d | 14 | ARG="$($1 --output BACK-FILE | awk '{if (1 < NR) {print}}')" |
c6f8c3f5 SK |
15 | COMPREPLY=( $(compgen -W "$ARG" -- $cur) ) |
16 | return 0 | |
17 | ;; | |
18 | '-c'|'--set-capacity') | |
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') | |
b5b80e5a BE |
28 | local prefix realcur OUTPUT_ALL OUTPUT |
29 | realcur="${cur##*,}" | |
30 | prefix="${cur%$realcur}" | |
31 | OUTPUT_ALL="NAME AUTOCLEAR BACK-FILE BACK-INO | |
c6f8c3f5 | 32 | BACK-MAJ:MIN MAJ:MIN OFFSET PARTSCAN RO |
d092911b | 33 | SIZELIMIT DIO" |
b5b80e5a BE |
34 | for WORD in $OUTPUT_ALL; do |
35 | if ! [[ $prefix == *"$WORD"* ]]; then | |
abbcec4f | 36 | OUTPUT="$WORD ${OUTPUT:-""}" |
b5b80e5a BE |
37 | fi |
38 | done | |
c6f8c3f5 | 39 | compopt -o nospace |
b5b80e5a | 40 | COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) ) |
c6f8c3f5 SK |
41 | return 0 |
42 | ;; | |
d4f9b8d7 VS |
43 | '-h'|'--help'|'-V'|'--version') |
44 | return 0 | |
45 | ;; | |
c6f8c3f5 SK |
46 | esac |
47 | case $cur in | |
48 | -*) | |
0d5b9b8a VS |
49 | OPTS="--all |
50 | --detach | |
51 | --detach-all | |
52 | --find | |
53 | --set-capacity | |
54 | --associated | |
d092911b | 55 | --nooverlap |
0d5b9b8a | 56 | --offset |
0d5b9b8a VS |
57 | --sizelimit |
58 | --partscan | |
59 | --read-only | |
60 | --show | |
61 | --verbose | |
d092911b SK |
62 | --json |
63 | --list | |
64 | --noheadings | |
65 | --output | |
289673b1 | 66 | --output-all |
d092911b | 67 | --raw |
0d5b9b8a VS |
68 | --help |
69 | --version" | |
c6f8c3f5 SK |
70 | COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) |
71 | return 0 | |
72 | ;; | |
73 | esac | |
ce3e6b15 | 74 | local IFS=$'\n' |
c6f8c3f5 SK |
75 | compopt -o filenames |
76 | COMPREPLY=( $(compgen -f -- $cur) ) | |
77 | return 0 | |
78 | } | |
79 | complete -F _losetup_module losetup |