Received: from eggs.gnu.org ([2001:4830:134:3::10]:40964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkBQW-0000n2-0S for qemu-devel@nongnu.org; Wed, 14 Sep 2016 10:44:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkBQR-0001I7-PQ for qemu-devel@nongnu.org; Wed, 14 Sep 2016 10:44:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53470) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkBQR-0001Hy-H4 for qemu-devel@nongnu.org; Wed, 14 Sep 2016 10:44:35 -0400 References: <1473772858-30881-1-git-send-email-thuth@redhat.com> <64a69157-6f90-dd7d-e1bc-9b319b91ec55@redhat.com> <20160913160647.GA30949@redhat.com> <80ea53df-39c9-1087-4a72-5a6dd050abc4@redhat.com> From: Eric Blake Message-ID: <5dbcf864-395d-455e-9af9-19449852820f@redhat.com> Date: Wed, 14 Sep 2016 09:44:33 -0500 MIME-Version: 1.0 In-Reply-To: <80ea53df-39c9-1087-4a72-5a6dd050abc4@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="w8OtGdw8qRvwxv89KCN1TH0LTL3Xr8BhB" 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: Thomas Huth , "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, Peter Maydell , stefanha@redhat.com, Paolo Bonzini This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --w8OtGdw8qRvwxv89KCN1TH0LTL3Xr8BhB From: Eric Blake To: Thomas Huth , "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, Peter Maydell , stefanha@redhat.com, Paolo Bonzini Message-ID: <5dbcf864-395d-455e-9af9-19449852820f@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2] scripts: Add a script to check for bug URLs in the git log References: <1473772858-30881-1-git-send-email-thuth@redhat.com> <64a69157-6f90-dd7d-e1bc-9b319b91ec55@redhat.com> <20160913160647.GA30949@redhat.com> <80ea53df-39c9-1087-4a72-5a6dd050abc4@redhat.com> In-Reply-To: <80ea53df-39c9-1087-4a72-5a6dd050abc4@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/14/2016 05:35 AM, Thomas Huth wrote: > Erik, It's Eric, but don't sweat it (you're not the first, and probably not the last, to typo names) >>>> +while [ $# -ge 1 ]; do >>>> + case "$1" in >>>> + -s) START=3D"$2" ; shift ;; >>> >>> POSIX recommends that short options with arguments be parseable both = as >>> '-s foo' and '-sfoo'. I don't care that you aren't POSIX compliant, = but >>> using getopt(1) or getopts(1) may make it easier to comply. >=20 > 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 getop= t > should not be used. getopts(1) is POSIX, but not universally present. I _think_ your script was portable to /bin/sh, but it may be easier to write by relying on bashisms and changing line one to /bin/bash, at which point we know getopts is present. >=20 > [...] >>>> +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 try= ing >>> to redirect to /dev/null to avoid shell messages when it does not exi= st, >>> but to properly do that, you'd need: >=20 > I rather wanted to simply suppress the output of which. >=20 > Is there a POSIX compliant way to check whether a program is available > in $PATH ? 'type' and 'command' are both supposed to be able to do it according to PSOIX, although there are probably portability pitfalls with both of them; again, using /bin/bash can avoid some of the concerns about portabilities. Sadly, both of those names are hard to grep for, so I can't quickly determine if we have existing shell scripts in qemu.git that have an example to copy from. >=20 >> 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 pyth= on >> or any other scripting language which isn't rammed full of portability= >> problems and shockingly awful error handling facilities as shell is. >=20 > 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 ..= =2E > well, maybe it's now time to improve it ;-) >=20 > Thomas >=20 >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --w8OtGdw8qRvwxv89KCN1TH0LTL3Xr8BhB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJX2WJRAAoJEKeha0olJ0NqaR4H/1FY4omGewIWzxQAswS6/F0c ABa7OoxLsubYIXLprTEOtZkrdkarkjmoosXIDfCSN2Ktz4LBGX2a/D/ARQBDOpSs 8YL1/c7gjvH4mOGq4EuvIQJW7ybzB+IHLHh0201XuQap2fczQS/ecco0BGLbqkvq 4q4Hx+7ag52XaOgVBt/4SPTIllB1Z8djhCBXBwjnbqnjtefJsO7vUsU0SUOeLQb0 Zva5s86RPANpwITlLX+8RtnI1CyS7PyjuZo23XRn0GXXTzYSsQgKcgAWEGnoFmJV bGpHIBeoj7o8YT7r9YHuTNFO+Mt83jX4uTccuI7u6Vscgmv5E245TWX39faxepU= =+j2u -----END PGP SIGNATURE----- --w8OtGdw8qRvwxv89KCN1TH0LTL3Xr8BhB--