This file is indexed.

/etc/bash_completion.d/apport_completion is in apport 2.14.1-0ubuntu3.29.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# 
# Apport bash-completion
#
###############################################################################

# get available symptoms
_apport_symptoms ()
{
    local syms
    if [ -r /usr/share/apport/symptoms ]; then 
        for FILE in $(ls /usr/share/apport/symptoms); do
            # hide utility files and symptoms that don't have a run() function
            if [[ ! "$FILE" =~ ^_.* && -n $(egrep "^def run\s*\(.*\):" /usr/share/apport/symptoms/$FILE) ]]; then
                syms="$syms ${FILE%.py}"
            fi
        done
    fi
    echo $syms

}

# completion when used without parameters
_apport_parameterless ()
{
    local param
    # parameter-less completion
    # param= COMMAND parameters
    #        package names
    #        PIDs
    #        Symptoms
    #        any file
    param="$dashoptions \
           $( apt-cache pkgnames $cur 2> /dev/null ) \
           $( command ps axo pid | sed 1d ) \
           $( _apport_symptoms ) \
           $( compgen -G "${cur}*" )"
    COMPREPLY=( $( compgen -W "$param" -- $cur) )

}

# apport-bug ubuntu-bug completion
_apport-bug ()
{
    local cur dashoptions prev param

    COMPREPLY=()
    cur=`_get_cword`
    prev=${COMP_WORDS[COMP_CWORD-1]}


    # available options
    dashoptions='-h --help --save -v --version --tag -w --window'

    case "$prev" in
    ubuntu-bug | apport-bug)
        case "$cur" in
        -*)
            # parameter completion
            COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )

        ;;
        *)
            # no parameter given
            _apport_parameterless 

        ;;
        esac

    ;;
    --save)
        COMPREPLY=( $( compgen -o default -G "$cur*" ) )
    
    ;;
    -w | --window)
        dashoptions="--save --tag"
        COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )
    ;;
    -h | --help | -v | --version | --tag)
        # standalone parameters
        return 0

    ;;
    *)
        # --save and --window make only sense once
        dashoptions="--tag"
        if ! [[ "${COMP_WORDS[*]}" =~ .*--save.* ]]; then
            dashoptions="--save $dashoptions"
        fi
        if ! [[ "${COMP_WORDS[*]}" =~ .*--window.* || "${COMP_WORDS[*]}" =~ .*\ -w\ .* ]]; then
            dashoptions="-w --window $dashoptions"
        fi

        case "$cur" in
        -*)
            # parameter completion
            COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )

        ;;
        *)
            _apport_parameterless 

        ;;
        esac

    ;;
    esac
}

# apport-cli completion
_apport-cli ()
{
    local cur dashoptions prev param

    COMPREPLY=()
    cur=`_get_cword`
    prev=${COMP_WORDS[COMP_CWORD-1]}


    # available options
    dashoptions='-h --help -f --file-bug -u --update-bug -s --symptom \
                 -c --crash-file --save -v --version --tag -w --window'

    case "$prev" in
    apport-cli)
        case "$cur" in
        -*)
            # parameter completion
            COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )

        ;;
        *)
            # no parameter given
            _apport_parameterless 

        ;;
        esac

    ;;
    -f | --file-bug)
        param="-P --pid -p --package -s --symptom"
        COMPREPLY=( $( compgen -W "$param $(_apport_symptoms)" -- $cur) )

    ;;
    -s | --symptom)
        COMPREPLY=( $( compgen -W "$(_apport_symptoms)" -- $cur) )

    ;;
    --save)
        COMPREPLY=( $( compgen -o default -G "$cur*" ) )
    
    ;;
    -c | --crash-file)
        # only show *.apport *.crash files
        COMPREPLY=( $( compgen -G "${cur}*.apport"
                       compgen -G "${cur}*.crash" ) )

    ;;
    -w | --window)
        dashoptions="--save --tag"
        COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )
    ;;
    -h | --help | -v | --version | --tag)
        # standalone parameters
        return 0

    ;;
    *)
        dashoptions='--tag'

        # most parameters only make sense once
        if ! [[ "${COMP_WORDS[*]}" =~ .*--save.* ]]; then
            dashoptions="--save $dashoptions"
        fi
        if ! [[ "${COMP_WORDS[*]}" =~ .*--window.* || "${COMP_WORDS[*]}" =~ .*\ -w\ .* ]]; then
            dashoptions="-w --window $dashoptions"
        fi
        if ! [[ "${COMP_WORDS[*]}" =~ .*--symptom.* || "${COMP_WORDS[*]}" =~ .*\ -s\ .* ]]; then
            dashoptions="-s --symptom $dashoptions"
        fi
        if ! [[ "${COMP_WORDS[*]}" =~ .*--update.* || "${COMP_WORDS[*]}" =~ .*\ -u\ .* ]]; then
            dashoptions="-u --update $dashoptions"
        fi
        if ! [[ "${COMP_WORDS[*]}" =~ .*--file-bug.* || "${COMP_WORDS[*]}" =~ .*\ -f\ .* ]]; then
            dashoptions="-f --file-bug $dashoptions"
        fi
        if ! [[ "${COMP_WORDS[*]}" =~ .*--crash-file.* || "${COMP_WORDS[*]}" =~ .*\ -c\ .* ]]; then
            dashoptions="-c --crash-file $dashoptions"
        fi

        # use same completion as if no parameter is given
        case "$cur" in
        -*)
            # parameter completion
            COMPREPLY=( $( compgen -W "$dashoptions" -- $cur ) )

        ;;
        *)
            _apport_parameterless 

        ;;
        esac

    ;;
    esac
}

# apport-unpack completion
_apport-unpack ()
{
    local cur prev

    COMPREPLY=()
    cur=`_get_cword`
    prev=${COMP_WORDS[COMP_CWORD-1]}

    case "$prev" in
    apport-unpack)
        # only show *.apport *.crash files
        COMPREPLY=( $( compgen -G "${cur}*.apport"
                       compgen -G "${cur}*.crash" ) )

    ;;
    esac
}

# apport-collect completion
_apport-collect ()
{
    local cur prev

    COMPREPLY=()
    cur=`_get_cword`
    prev=${COMP_WORDS[COMP_CWORD-1]}

    case "$prev" in 
    apport-collect)
        COMPREPLY=( $( compgen -W "-p --package --tag" -- $cur) )

    ;;
    -p | --package)
        # list package names
        COMPREPLY=( $( apt-cache pkgnames $cur 2> /dev/null ) )

    ;;
    --tag)
        # standalone parameter
        return 0
    ;;
    *)
        # only complete -p/--package once
        if [[ "${COMP_WORDS[*]}" =~ .*\ -p.* || "${COMP_WORDS[*]}" =~ .*--package.* ]]; then
            COMPREPLY=( $( compgen -W "--tag" -- $cur) )
        else
            COMPREPLY=( $( compgen -W "-p --package --tag" -- $cur) )
        fi
        
    ;;
    esac
}

# bind completion to apport commands
complete -F _apport-bug -o filenames -o dirnames ubuntu-bug
complete -F _apport-bug -o filenames -o dirnames apport-bug
complete -F _apport-cli -o filenames -o dirnames apport-cli
complete -F _apport-unpack -o filenames -o dirnames apport-unpack
complete -F _apport-collect apport-collect

# vi: syntax=bash