zsh-workers
 help / color / mirror / code / Atom feed
3388f3338ed121741a596b86112de95095ef32b0 blob 1842 bytes (raw)

 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
 
#compdef lsusb

local context state line
typeset -A opt_args

_arguments \
  '(-v --verbose)'{-v,--verbose}'[be verbose]' \
  '-s[Narrow to some devices]:bus and/or devnum to show:->bus_devnum' \
  '-d:vendor and product to show:->vendor_product' \
  '-D:device to show:_files -g "*(%)"' \
  '-t[dump the physical USB device hierarchy as a tree]' \
  '(-)'{-V,--version}'[print version info and exit]' && return 0

case "$state" in
  (bus_devnum)
    local B bus D device I id descr bus_dev
    _call_program usb_devices lsusb \
      | while IFS=" " read -r  B bus D device I id descr
    do
        if [[ $B$D$I != BusDeviceID ]]
        then
            echo "Internal error: Unknown lsusb output line:" \
              "$B $bus $D $device $I $id $descr" >&2
        else
            bus_dev+=(${(M)bus%%[1-9]*}\\:${${(M)device%%[1-9]*}%:}:$descr)
        fi
    done
    _describe -t usb_addresses 'usb device address' bus_dev
    ;;

  (vendor_product)
    if ! (( ${+_cache_lsusb_devices} ))
    then
        local id name last_vendor_id
        while IFS=" " read -r id name
        do
            case "$id" in
              (*\#*|)
                ;;
              ('		'*)
                # interface interface_name
                ;;
              ('	'*)
                # device_id device_name
                _cache_lsusb_devices+=($last_vendor_id\\:${id#	}:$name)
                ;;
              ([!0-9a-f]*)
                # Here start other entries like classes (C) and languages (L)
                break
                ;;
              (*)
                last_vendor_id=$id
                ;;
            esac
        done < /var/lib/usbutils/usb.ids
    fi

    _describe -t usb_device_ids 'usb device ids' _cache_lsusb_devices
    ;;

  (*)
    echo "Internal error: Unknown state: $state" >&2
    return 1
    ;;
esac
debug log:

solving 3388f33 ...
found 3388f33 in https://inbox.vuxu.org/zsh-workers/1235729886-11033-1-git-send-email-joerg@alea.gnuu.de/
found 37701ac in https://git.vuxu.org/mirror/zsh/
preparing index
index prepared:
100644 37701acd5a1e0983094164bd49584af24119caf4	Completion/Linux/Command/_lsusb

applying [1/1] https://inbox.vuxu.org/zsh-workers/1235729886-11033-1-git-send-email-joerg@alea.gnuu.de/
diff --git a/Completion/Linux/Command/_lsusb b/Completion/Linux/Command/_lsusb
index 37701ac..3388f33 100644

Checking patch Completion/Linux/Command/_lsusb...
Applied patch Completion/Linux/Command/_lsusb cleanly.

index at:
100644 3388f3338ed121741a596b86112de95095ef32b0	Completion/Linux/Command/_lsusb

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).