FIXUP: give names to sec_vt_command's
[wireshark-wip.git] / tools / gen-bugnote
blob1b753f845d67fe65212fdd9e4454a149618c8d7b
1 #!/bin/bash
3 # Given a Wireshark bug ID, fetch its title and prepare an entry suitable
4 # for pasting into the release notes. Requires curl, grep, and sed.
6 # Usage: gen-bugnote <bug number>
8 # $Id$
10 # Copyright 2013 Gerald Combs
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 2
15 # of the License, or (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 output_fmt="docbook"
28 if [ -f release-notes.asciidoc -o -f docbook/release-notes.asciidoc ] ; then
29 output_fmt="asciidoc"
32 while getopts "o:" OPT ; do
33 case $OPT in
34 o) output_fmt=$OPTARG
36 esac
37 done
38 shift $(($OPTIND - 1))
40 bz_url_pfx="https://bugs.wireshark.org/bugzilla/show_bug.cgi?id="
41 bug_id="$1"
43 recode_cmd="cat"
44 hash recode > /dev/null 2>&1 && recode_cmd="recode html..utf8"
46 case "$OSTYPE" in
47 darwin*)
48 clipboard_cmd="pbcopy -Pascii"
50 cygwin*)
51 clipboard_cmd="cat > /dev/clipboard"
53 linux*)
54 clipboard_cmd="xsel --clipboard"
57 echo "Unable to copy to clipboard"
58 clipboard_cmd="cat > /dev/null"
60 esac
62 if [ -z "$bug_id" ] ; then
63 echo "Usage: " `basename $0` " <bug id>"
64 exit 1
67 bug_title=`
68 curl -s -o - "https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=$bug_id" |
69 grep -i '<title>' |
70 sed \
71 -e 's:.*<title>.*ndash; ::' \
72 -e 's:</title>.*::' \
73 -e 's/[^\.]$/&./' \
76 case "$output_fmt" in
77 asciidoc)
78 echo -e "* $bug_title (ws-buglink:$bug_id[])\n" \
79 | $recode_cmd \
80 | $clipboard_cmd
82 docbook)
83 $clipboard_cmd <<Fin
84 <listitem><para>
85 $bug_title
86 (<ulink url="https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=$bug_id">Bug
87 $bug_id</ulink>)
88 </para></listitem>
90 Fin
92 esac
94 echo "Copied $bug_id: $bug_title"