2013-04-23 19:21:18 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Given a Wireshark bug ID, fetch its title and prepare an entry suitable
|
|
|
|
# for pasting into the release notes. Requires curl, grep, and sed.
|
|
|
|
#
|
|
|
|
# Usage: gen-bugnote <bug number>
|
|
|
|
#
|
|
|
|
# Copyright 2013 Gerald Combs
|
|
|
|
#
|
2018-03-07 14:28:51 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2013-04-23 19:21:18 +00:00
|
|
|
#
|
|
|
|
|
2018-06-07 22:03:48 +00:00
|
|
|
bz_url_pfx="https://bugs.wireshark.org/bugzilla/show_bug.cgi"
|
2013-04-23 19:21:18 +00:00
|
|
|
bug_id="$1"
|
|
|
|
|
2020-01-13 21:53:04 +00:00
|
|
|
# Bugzilla gives us UTF-8 with HTML escapes. We want UTF-8. Recode assumes
|
|
|
|
# that HTML is encoded as ISO-8859-1.
|
|
|
|
# https://github.com/rrthomas/Recode/issues/1
|
2020-01-13 22:11:42 +00:00
|
|
|
recode_to_html_cmd="cat"
|
|
|
|
if hash recode > /dev/null 2>&1 ; then
|
|
|
|
recode_to_html_cmd="recode utf8..html"
|
|
|
|
recode_to_utf8_cmd="recode html..utf8"
|
|
|
|
fi
|
2013-09-07 00:18:10 +00:00
|
|
|
|
2013-04-23 19:21:18 +00:00
|
|
|
case "$OSTYPE" in
|
|
|
|
darwin*)
|
|
|
|
clipboard_cmd="pbcopy -Pascii"
|
|
|
|
;;
|
|
|
|
cygwin*)
|
|
|
|
clipboard_cmd="cat > /dev/clipboard"
|
|
|
|
;;
|
|
|
|
linux*)
|
|
|
|
clipboard_cmd="xsel --clipboard"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unable to copy to clipboard"
|
|
|
|
clipboard_cmd="cat > /dev/null"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ -z "$bug_id" ] ; then
|
2018-06-07 22:03:48 +00:00
|
|
|
echo "Usage: $( basename "$0" ) <bug id>"
|
2013-04-23 19:21:18 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-12-19 19:04:09 +00:00
|
|
|
bug_title=$(
|
2018-06-07 22:03:48 +00:00
|
|
|
curl -s -o - "${bz_url_pfx}?id=$bug_id" \
|
2016-12-19 19:04:09 +00:00
|
|
|
| grep -i '<title>' \
|
|
|
|
| sed \
|
2019-04-05 16:25:27 +00:00
|
|
|
-e 's/{/\\{/g' \
|
2013-04-23 19:21:18 +00:00
|
|
|
-e 's:.*<title>.*ndash; ::' \
|
2019-04-05 16:25:27 +00:00
|
|
|
-e 's:</title>.*::g' \
|
|
|
|
-e 's/[^\.]$/&./g' \
|
|
|
|
-e 's/\\/{backslash}/g' \
|
2016-12-19 19:04:09 +00:00
|
|
|
)
|
2013-04-23 19:21:18 +00:00
|
|
|
|
2018-07-17 19:08:01 +00:00
|
|
|
echo -e "* $bug_title wsbuglink:${bug_id}[].\\n" \
|
2020-01-13 22:11:42 +00:00
|
|
|
| $recode_to_html_cmd \
|
|
|
|
| $recode_to_utf8_cmd \
|
2014-02-24 23:58:47 +00:00
|
|
|
| $clipboard_cmd
|
2013-04-23 19:21:18 +00:00
|
|
|
|
|
|
|
echo "Copied $bug_id: $bug_title"
|