Showing 1 changed files with 45 additions and 29 deletions
+45 -29
flightgear/fgfs_function
... ...
@@ -266,7 +266,6 @@ function fgfs () {
266 266
                     return
267 267
                     ;;
268 268
                 --info)
269
-                    local PS3='which aircraft ? '
270 269
                     local IFS=$'\n'
271 270
                     function _info () {
272 271
                         local _info=$(sqlite3 $FGADDON/fgaddon.db <<< "select \`$1\`
... ...
@@ -284,7 +283,7 @@ function fgfs () {
284 283
                             printf "%s: %s\n" "$2" "$_info"
285 284
                         fi
286 285
                     }
287
-                    select ac in $(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]',
286
+                    local ac_list=($(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]',
288 287
                                                                    aircrafts.name,
289 288
                                                                    hangars.name,
290 289
                                                                    date(aircrafts.date, 'unixepoch'))
... ...
@@ -296,26 +295,34 @@ function fgfs () {
296 295
                                                        setxml.variantof = aircrafts.id
297 296
                                                      and
298 297
                                                          setxml.file = '$2'
299
-                                                     order by aircrafts.date desc"); do
300
-                        test -z "$ac" && continue
301
-                        local file=$2
302
-                        _info /sim/description      "Short description"
303
-                        _info /sim/long-description "Long description"
304
-                        _info /sim/author           "Author(s)"
305
-                        _info /sim/flight-model     "Flight model"
306
-                        _info /sim/type             "Type"
307
-                        echo Ratings
308
-                        for r in FDM systems cockpit model; do
309
-                            _info /sim/rating/$r "  $r"
298
+                                                     order by aircrafts.date desc"))
299
+                    if test ${#ac_list[@]} -gt 1; then
300
+                        local PS3='which aircraft ? '
301
+                        select ac in ${ac_list[@]}; do
302
+                            test -z "$ac" && continue
303
+                            break
310 304
                         done
305
+                    elif test ${#ac_list[@]} -eq 1; then
306
+                        ac=${ac_list[1]}
307
+                    else
311 308
                         return
309
+                    fi
310
+                    local file=$2
311
+                    _info /sim/description      "Short description"
312
+                    _info /sim/long-description "Long description"
313
+                    _info /sim/author           "Author(s)"
314
+                    _info /sim/flight-model     "Flight model"
315
+                    _info /sim/type             "Type"
316
+                    echo Ratings
317
+                    for r in FDM systems cockpit model; do
318
+                        _info /sim/rating/$r "  $r"
312 319
                     done
313 320
                     return
314 321
                     ;;
315 322
                 --show-thumbnail)
316 323
                     local PS3='which aircraft ? '
317 324
                     local IFS=$'\n'
318
-                    select ac in $(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]',
325
+                    local ac_list=($(sqlite3 $FGADDON/fgaddon.db <<< "select distinct printf('%s [%s, %s]',
319 326
                                                                    aircrafts.name,
320 327
                                                                    hangars.name,
321 328
                                                                    date(aircrafts.date, 'unixepoch'))
... ...
@@ -330,21 +337,30 @@ function fgfs () {
330 337
                                                        or
331 338
                                                          aircrafts.name like '%$2%'
332 339
                                                      )
333
-                                                     order by aircrafts.date desc"); do
334
-                        test -z "$ac" && continue
335
-                        local url=$(sqlite3 $FGADDON/fgaddon.db <<< "select printf('%s/${${(@s/ /)ac}[1]}', url)
336
-                                                                     from hangars where name = '${${(@s/ /)ac}[2]:1:-1}'")
337
-                        if test ${${(@s/ /)ac}[2]:1:-1} = 'FGMEMBERS'; then
338
-                            url="https://raw.githubusercontent.com/FGMEMBERS/${${(@s/ /)ac}[1]}/master"
339
-                        fi
340
-                        if wget --quiet --spider "$url/thumbnail.jpg"; then
341
-                            curl -s "$url/thumbnail.jpg" \
342
-                            | convert - -resize '200%' -normalize -sharpen '0.0x1.0' - \
343
-                            | display
344
-                        else
345
-                            echo "can't find or get thumbnail for ${${(@s/ /)ac}[1]} (${${(@s/ /)ac}[2]:1:-1}'s hangar)"
346
-                        fi
347
-                    done
340
+                                                     order by aircrafts.date desc"))
341
+                    if test ${#ac_list[@]} -gt 1; then
342
+                        local PS3='which aircraft ? '
343
+                        select ac in ${ac_list[@]}; do
344
+                            test -z "$ac" && continue
345
+                            break
346
+                        done
347
+                    elif test ${#ac_list[@]} -eq 1; then
348
+                        ac=${ac_list[1]}
349
+                    else
350
+                        return
351
+                    fi
352
+                    local url=$(sqlite3 $FGADDON/fgaddon.db <<< "select printf('%s/${${(@s/ /)ac}[1]}', url)
353
+                                                                 from hangars where name = '${${(@s/ /)ac}[2]:1:-1}'")
354
+                    if test ${${(@s/ /)ac}[2]:1:-1} = 'FGMEMBERS'; then
355
+                        url="https://raw.githubusercontent.com/FGMEMBERS/${${(@s/ /)ac}[1]}/master"
356
+                    fi
357
+                    if wget --quiet --spider "$url/thumbnail.jpg"; then
358
+                        curl -s "$url/thumbnail.jpg" \
359
+                        | convert - -resize '200%' -normalize -sharpen '0.0x1.0' - \
360
+                        | display
361
+                    else
362
+                        echo "can't find or get thumbnail for ${${(@s/ /)ac}[1]} (${${(@s/ /)ac}[2]:1:-1}'s hangar)"
363
+                    fi
348 364
                     return
349 365
                     ;;
350 366
                 --search)