summaryrefslogtreecommitdiff
path: root/bin/wtf
blob: 232ffe7062d00a4d6569cfa4e3e50aca845bbb5b (plain)
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
#!/bin/sh

# shellcheck disable=SC2119,SC2120

# shellcheck source=../lib/load-configuration
. "${0%/*}/../lib/load-configuration"

# TODO: search i486, too

search="$*"

pkgfile -wC "${base_dir}/misc/pacman-i686.conf" -s "${search##*/}" | \
  xargs -rn1 pkgfile -wC "${base_dir}/misc/pacman-i686.conf" -l | \
  if printf '%s\n' "${search}" | \
    grep -q '^/'; then
    grep -w "${search}" || true
  else
    grep "/${search}\\(/\\|\$\\)" || true
  fi | \
  sort -k2,2 | \
  sed '
    s,^\([^/[:space:]]\+\)/\([^/[:space:]]\+\)\s\(\S.*\)$,\2 [\1]: \3,
  ' | \
  sed '
    :a
    $!N
    s#^\(\([^/:[:space:]]\+ [^/:[:space:]]\+, \)*[^/:[:space:]]\+ [^/:[:space:]]\+\): \([^\n]\+\)\n\([^/:[:space:]]\+ [^/:[:space:]]\+\): \3$#\1, \4: \3#
    ta
    P
    D
  '