Received: from eggs.gnu.org ([2001:4830:134:3::10]:40912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bk7X4-0004ch-WF for qemu-devel@nongnu.org; Wed, 14 Sep 2016 06:35:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bk7X0-0005S2-Po for qemu-devel@nongnu.org; Wed, 14 Sep 2016 06:35:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bk7X0-0005Qb-II for qemu-devel@nongnu.org; Wed, 14 Sep 2016 06:35:06 -0400 References: <1473772858-30881-1-git-send-email-thuth@redhat.com> <64a69157-6f90-dd7d-e1bc-9b319b91ec55@redhat.com> <20160913160647.GA30949@redhat.com> From: Thomas Huth Message-ID: <80ea53df-39c9-1087-4a72-5a6dd050abc4@redhat.com> Date: Wed, 14 Sep 2016 12:35:02 +0200 MIME-Version: 1.0 In-Reply-To: <20160913160647.GA30949@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2] scripts: Add a script to check for bug URLs in the git log List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , Eric Blake Cc: qemu-devel@nongnu.org, Peter Maydell , stefanha@redhat.com, Paolo Bonzini Erik, thanks a lot for your detailed review and comments ... I somewhat suspected that my shell-script-fu is crap, but now I also have the confirmation ;-) Anyway, some comments below... On 13.09.2016 18:06, Daniel P. Berrange wrote: > On Tue, Sep 13, 2016 at 10:48:46AM -0500, Eric Blake wrote: >> On 09/13/2016 08:20 AM, Thomas Huth wrote: >>> Basic idea of this script is to check the git log for URLs >>> to the QEMU bugtracker at launchpad.net and to figure out >>> whether the related bug has been marked there as "Fix released" >>> (i.e. closed) already. So this script can e.g. be used after >>> each public release of QEMU to check whether there are any >>> bug tickets that could be moved from "Fix committed" (or another >>> state if the author of the patch forgot to update the bug ticket) >>> to "Fix released". >>> >>> Signed-off-by: Thomas Huth >>> --- >>> v2: >>> - Use xdg-open and friends to open the URLs in a browser >>> - Some cosmetics >>> >>> scripts/show-fixed-bugs.sh | 91 ++++++++++++++++++++++++++++++++++++= ++++++++++ >>> 1 file changed, 91 insertions(+) >>> create mode 100755 scripts/show-fixed-bugs.sh >>> >>> diff --git a/scripts/show-fixed-bugs.sh b/scripts/show-fixed-bugs.sh >>> new file mode 100755 >>> index 0000000..89847bd >>> --- /dev/null >>> +++ b/scripts/show-fixed-bugs.sh >>> @@ -0,0 +1,91 @@ >>> +#!/bin/sh >>> + >>> +# This script checks the git log for URLs to the QEMU launchpad bugt= racker >>> +# and optionally checks whether the corresponding bugs are not close= d yet. >>> + >>> +function show_help { >>> + echo "Usage:" >>> + echo " -s : Start searching at this commit" >>> + echo " -e : End searching at this commit" >>> + echo " -c : Check if bugs are still open" >>> + echo " -b : Open bugs in browser" >>> +} >>> + >>> +while [ $# -ge 1 ]; do >>> + case "$1" in >>> + -s) START=3D"$2" ; shift ;; >> >> POSIX recommends that short options with arguments be parseable both a= s >> '-s foo' and '-sfoo'. I don't care that you aren't POSIX compliant, b= ut >> using getopt(1) or getopts(1) may make it easier to comply. OK. After googling a little bit, it sounds like getopts is the way to go, e.g. http://mywiki.wooledge.org/BashFAQ/035#getopts says that getopt should not be used. [...] >>> +if [ "x$BROWSER" !=3D "x" ]; then >>> + BUGBROWSER =3D "$BROWSER" >>> +elif which xdg-open > /dev/null; then >> >> 'which' is not portable; it may not exist. It looks like you are tryi= ng >> to redirect to /dev/null to avoid shell messages when it does not exis= t, >> but to properly do that, you'd need: I rather wanted to simply suppress the output of which. Is there a POSIX compliant way to check whether a program is available in $PATH ? > Your various comments above are a great example of why IMHO any script = that > is longer than 1 line shouldn't be written in shell. Instead pick pytho= n > or any other scripting language which isn't rammed full of portability > problems and shockingly awful error handling facilities as shell is. I fully agree with you that writing portable shell-scripts is a pain, but unfortunately my python-fu is even worse than my shell-script-fu ... well, maybe it's now time to improve it ;-) Thomas