-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbgo
More file actions
executable file
·40 lines (37 loc) · 1.59 KB
/
bgo
File metadata and controls
executable file
·40 lines (37 loc) · 1.59 KB
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
#!/bin/bash
BGO="https://bugs.gentoo.org"
green="\033[01;32m"
red="\033[01;31m"
restore="\033[00m"
contrast="\033[1m"
underline="\033[4m"
if ! grep -q "bug=" <<< "${1}";then
URL="https://bugs.gentoo.org/buglist.cgi?quicksearch=${1}"
CONTENT="$(curl -s ${URL} 2>/dev/null)"
BUGS="$(echo "${CONTENT}" | grep "a href=\"show_bug.cgi?id=.*[a-z].*\<" | cut -d \= -f2,3 | sed -e 's|>.*||' -e 's|\"||g')"
for bug_full in ${BUGS};do
url="${BGO}/${bug_full}"
id="${bug_full#*=}"
desc="$(grep "${bug_full}.*[a-z].*\<" <<< "${CONTENT}")"
desc="${desc#*\>}"
desc="${desc%%\<*}"
status="$(echo "${CONTENT}" | grep -A1 ${id} | awk '/bz_[[:upper:]]/ {print $3}' | sed 's|bz_||')"
echo -e "${status}\t${green}${id}${restore}: ${desc}" | sed -e 's|"|\"|g;s|>|\>|g;s|<|\<|g'
done
else
id="${1#bug=}"
URL="https://bugs.gentoo.org/show_bug.cgi?id=${id}"
CONTENT="$(curl -s ${URL} 2>/dev/null)"
status="$(echo "${CONTENT}" | awk '/bz_status/ {print $3}' | sed 's|bz_status_||')"
desc="$(grep "Bug ${id} &ndash" <<< "${CONTENT}")"
desc="${desc#*\;}"
desc="${desc%\<*}"
echo -e "${status}\t${green}${id}${restore}: ${desc}" | sed -e 's|"|\"|g;s|>|\>|g;s|<|\<|g'
echo -e "Attachments:"
while read line;do
name="${line#*title=\"}"
name="${name%\"*}"
href="${BGO}/attachment.cgi?id=${line%&*}"
[[ -n "${name}" ]] && echo -e "${underline}${href}${restore} ${name}"
done <<< "$(echo "${CONTENT}" | grep "href=\"attachment.cgi?id=.*title" | sed 's|.*id=||')"
fi