This file is indexed.

/usr/share/bash-completion/completions/fgfs is in flightgear 1:2018.1.1+dfsg-1.

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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# © 2014 Raphael Dümig ( duemig at in dot tum dot de ) forum handle: "hamster"
# distributed under the terms of the GPLv3

local_config_file="$HOME/.fgfsrc"

_get_opt()
{
    local opt len
    opt=$1
    len=`expr ${#opt} + 3`
    
    if [ -e "$local_config_file" ]
    then
        stored_opts="$(cat "$local_config_file")"
    fi
    
    for word in $stored_opts "${words[@]}"
    do
        if [ "${word:0:$len}" == "--$opt=" ]
        then
            # TODO: we have to get rid of at least the most important escape sequences!!!
            value="$(echo "${word:$len}" | sed 's/\\ / /g')"
        fi
    done
}

_get_opts()
{
    local opt len
    opt=$1
    len=`expr ${#opt} + 3`
    value=""
    
    if [ -e "$local_config_file" ]
    then
        stored_opts="$(cat "$local_config_file")"
    fi
    
    for word in "$stored_opts ${words[@]}"
    do
        if [ "${word:0:$len}" == "--$opt=" ]
        then
            value+="$(echo "${word:$len}" | sed 's/\\ / /g') "
        fi
    done
}

_get_fg_root()
{
    local value
    _get_opt "fg-root"
    
    # value on the command line?
    if [ -n "$value" ]
    then
        root="$value"
        return 0
    # value stored in environment variable $FG_ROOT?
    else if [ -n "$FG_ROOT" ]
    then
        root="$FG_ROOT"
        return 0
    # no clue! search at the most common places
    else
        for path in /usr{/local,}/share{/games,}/{F,f}light{G,g}ear{/data,} {~,}/Applications/FlightGear.app/Contents/Resources/data
        do
            if [ -e "$path" ]
            then
                root="$path"
                break
            fi
        done
    fi
    fi
}

_get_fg_scenery()
{
    local value
    _get_opt "fg-scenery"
    
    # value on command line?
    if [ -n "$value" ]
    then
        scenery="$value"
    # value stored in environment variable $FG_SCENERY?
    else if [ -n "$FG_SCENERY" ]
    then
        scenery="$FG_SCENERY"
    # no clue! try default:
    else
        local root
        _get_fg_root
        scenery="$root/Scenery"
    fi
    fi
    
    return 0
}

_get_fg_aircraft()
{
    local value
    _get_opt "fg-aircraft"
    
    # value on command line?
    if [ -n "$value" ]
    then
        aircraft_dir="$value"
    # value stored in environment variable $FG_AIRCRAFT?
    else if [ -n "$FG_AIRCRAFT" ]
    then
        aircraft_dir="$FG_AIRCRAFT"
    # no clue! try default:
    else
        local root
        _get_fg_root
        aircraft_dir="$root/Aircraft"
    fi
    fi
}

_get_airport()
{
    local value
    _get_opt "airport"
    
    if [ -z "$value" ]
    then
        airport="KSFO"
    else
        airport=$value
    fi
}

_get_carrier()
{
    local value
    _get_opt "carrier"
    
    carrier=$value
}

_get_scenarios()
{
    local value
    _get_opts "ai-scenario"
    
    scenarios="$value nimitz_demo"
}


_fgfs() 
{
    local cur prev words cword split
    _init_completion -s || return

    local root airport aircraft_dir carrier scenarios scenery value
    
    # auto-completion for values of keys ( --key=value )
    case "$prev" in
        --fg-aircraft|--fg-root|--fg-scenery|--flight-plan|--terrasync-dir|--materials-file|--config|--browser-app)
            # completion of filesystem path
            _filedir
            return 0 ;;
        --ai-scenario)
            # list of scenarios in $FG_ROOT/AI
            _get_fg_root
            scenarios="$(find "$root/AI" -maxdepth 1 -iname *.xml -printf '%f\n' | sed -e 's/.xml$//')"
            
            COMPREPLY=( $(compgen -W "${scenarios}" -- ${cur}) )
            return 0 ;;
        --aircraft|--vehicle)
            # list of aircrafts in $FG_AIRCRAFT
            _get_fg_aircraft
            aircrafts="$(find "$aircraft_dir" -maxdepth 2 -mindepth 2 -iname *-set.xml -printf '%f\n' | sed -e 's/-set.xml$//')"
            
            COMPREPLY=( $(compgen -W "${aircrafts}" -- ${cur}) )
            return 0 ;;
        --airport)
            _get_fg_root
            _get_fg_scenery
            # is an index file present in the scenery?
            if [ -e "$scenery/Airports/index.txt" ]
            then
                COMPREPLY=( $(compgen -W "$(awk 'BEGIN { FS="|"; } { print $1 }' "$scenery/Airports/index.txt")" -- ${cur}) )
                return 0
            # or at least the apt.dat file?
            else if [ -e "$root/Airports/apt.dat.gz" ]
            then
                COMPREPLY=( $(compgen -W "$(zcat "$root/Airports/apt.dat.gz" | awk '/^1 / { print $5 }')" -- ${cur}) )
                return 0
            fi
            fi
            
            return 0 ;;
        --carrier)
            _get_fg_root
            _get_scenarios
            
            carriers=""
            
            for scenario in $scenarios
            do
                carriers+="$(awk -- '
BEGIN { carrier=0; name=""; }
/<type>/ {
    a=index($0,"<type>")+6; s=index(substr($0,a),"</type>")-1;
    if(substr($0,a,s) == "carrier") carrier=1;
}
/<name>/ {
    if(carrier) {
        a=index($0,"<name>")+6; s=index(substr($0,a),"</name>")-1;
        print substr($0,a,s);
        carrier=0;
    }
}
/<\/entry>/ {
    carrier=0;
    name="";
}' "$root/AI/$scenario.xml") "
            done
            
            COMPREPLY=( $(compgen -W "${carriers}" ${cur}) )
            return 0 ;;
        --runway)
            _get_fg_scenery
            _get_airport
            
            # try to find a thresholds file
            path="$scenery/Airports/${airport:0:1}/${airport:1:1}/${airport:2:1}"
            
            if [ -e "$path/$airport.threshold.xml" ]
            then
                runways="$(awk -- '
/<rwy>/ {
    a=index($0,"<rwy>")+5;
    s=index(substr($0,a),"</rwy>")-1;
    print substr($0,a,s)
}' "$path/$airport.threshold.xml")"
            fi
            
            COMPREPLY=( $(compgen -W "${runways}" -- ${cur}) )
            return 0 ;;
        --parkpos)
            # try to find out the name of the carrier or the ID of the airport
            _get_carrier
            
            if [ -n "$carrier" ]
            then
                _get_fg_root
                _get_scenarios
                
                for scenario in $scenarios
                do
                    positions="$(awk -v carrier_name="$carrier" '
BEGIN { carrier=0; name=0; parkpos=0; }
/<type>/ {
    a=index($0,"<type>")+6; s=index(substr($0,a),"</type>")-1;
    if(substr($0,a,s) == "carrier") carrier=1;
}
/<parking-pos>/ {
    parkpos=(carrier && name);
}
/<name>/ {
    a=index($0,"<name>")+6; s=index(substr($0,a),"</name>")-1;
    if(parkpos) print substr($0,a,s);
    else if(carrier) name=(substr($0,a,s) == carrier_name);
}
/<\/parking-pos>/ {
    parkpos=0;
}
/<\/entry>/ {
    carrier=name=parkpos=0;
}' "$root/AI/$scenario.xml")"
                    
                    if [ -n "$positions" ]
                    then
                        break
                    fi
                done
                
            else
                _get_fg_scenery
                _get_airport
                
                # search for the groundnet or parking file
                path="$scenery/Airports/${airport:0:1}/${airport:1:1}/${airport:2:1}"
                
                if [ -e "$path/$airport.groundnet.xml" ]
                then
                    file="$airport.groundnet.xml"
                else if [ -e "$path/$airport.parking.xml" ]
                then
                    file="$airport.parking.xml"
                else
                    # no file found => do not try to analyze it!
                    return 0
                fi
                fi
                
                # build a list of the parking positions at that airport
                positions="$(awk -- '
/<Parking/ {
    pos_active=1;
    name=number="";
}
/name="/ {
    if(pos_active) {
        a=index($0,"name=\"")+6;
        s=index(substr($0,a),"\"")-1;
        name=substr($0,a,s);
    }
}
/number="/ {
    if(pos_active) {
        a=index($0,"number=\"")+8;
        s=index(substr($0,a),"\"")-1;
        number=substr($0,a,s);
    }
}
/\/>/ {
    if(pos_active == 1 && (name!="" || number!="")) print name number;
    pos_active=0;
    name=number="";
}' "$path/$file")"
            fi
            
            COMPREPLY=( $(compgen -W "${positions}" -- ${cur}) )
            return 0 ;;
        --control)
            COMPREPLY=( $(compgen -W "joystick keyboard mouse" -- ${cur}) )
            return 0 ;;
        --failure)
            COMPREPLY=( $(compgen -W "pitot static vacuum electrical" -- ${cur}) )
            return 0 ;;
        --fix)
            _get_fg_root
            COMPREPLY=( $(compgen -W "$(zcat "$root/Navaids/fix.dat.gz" | awk '{ print substr($3,0,5) }')" -- ${cur}) )
            return 0 ;;
        --fdm)
            COMPREPLY=( $(compgen -W "jsb larcsim yasim magic balloon ada external null" -- ${cur}) )
            return 0 ;;
        --min-status)
            COMPREPLY=( $(compgen -W "alpha beta early-production production" -- ${cur}) )
            return 0 ;;
        --log-class)
            COMPREPLY=( $(compgen -W "ai environment flight general io network sound terrain" -- ${cur}) )
            return 0 ;;
        --log-level)
            COMPREPLY=( $(compgen -W "bulk debug info warn alert" -- ${cur}) )
            return 0 ;;
        --ndb)
            _get_fg_root
            COMPREPLY=( $(compgen -W "$(zcat "$root/Navaids/nav.dat.gz" | awk '/^2 / { print $8 }')" -- ${cur}) )
            return 0 ;;
        --ndb-frequency)
            _get_fg_root
            _get_opt "ndb"
            COMPREPLY=( $(compgen -W "$(zcat "$root/Navaids/nav.dat.gz" | awk -v nav=$value '/^2 / { if($8 == nav) print $5 }')" -- ${cur}) )
            return 0 ;;
        --season)
            COMPREPLY=( $(compgen -W "summer winter" -- ${cur}) )
            return 0 ;;
        --texture-filtering)
            COMPREPLY=( $(compgen -W "1 2 4 8 16" -- ${cur}) )
            return 0 ;;
        --timeofday)
            COMPREPLY=( $(compgen -W "real dawn morning noon afternoon dusk evening midnight" -- ${cur}) )
            return 0 ;;
        --view-offset)
            COMPREPLY=( $(compgen -W "LEFT RIGHT CENTER" -- ${cur}) )
            return 0 ;;
        --vor)
            _get_fg_root
            COMPREPLY=( $(compgen -W "$(zcat "$root/Navaids/nav.dat.gz" | awk '/^3 / { print $8 }')" -- ${cur}) )
            return 0 ;;
        --vor-frequency)
            _get_fg_root
            _get_opt "vor"
            COMPREPLY=( $(compgen -W "$(zcat "$root/Navaids/nav.dat.gz" | awk -v nav=$value '/^3 / { if($8 == nav) print substr($5,0,3) "." substr($5,4) }')" -- ${cur}) )
            return 0 ;;
    esac
    
    case "${cur}" in
        -*)
            # auto completion for options
            COMPREPLY=( $(compgen -W "$(_parse_help fgfs "--help --verbose")" -- ${cur}) )
            # no whitespace after keys
            [[ $COMPREPLY == *= ]] && compopt -o nospace ;;
        *)
            _filedir
    esac
    
    return 0
}
complete -F _fgfs fgfs