From: <Mikko.Rapeli@bmw.de>
To: <ed.bartosh@linux.intel.com>
Cc: openembedded-core@lists.openembedded.org
Subject: shell script guidelines in oe-core? (was Re: [PATCH v4] create-pull-request: cleanup bashisms)
Date: Wed, 12 Aug 2015 09:49:50 +0000 [thread overview]
Message-ID: <20150812094953.GL6102@loska> (raw)
In-Reply-To: <1439372011-26268-1-git-send-email-ed.bartosh@linux.intel.com>
Sorry to hijack the thread but...
On Wed, Aug 12, 2015 at 12:33:31PM +0300, Ed Bartosh wrote:
> Made create-pull-request POSIX compatible:
> - Replaced /bin/bash -> /bin/sh in shebang.
> - Replaced usage of pushd/popd with generic shell commands.
> - Tested on zsh and dash.
This reminded me of the problems I've seen with various oe-core shell scripts:
they are missing systematic error handling.
IMO using bash and 'set -euxo pipefail' are a good approach to catch errors
early in shell scripts. Manually checking for $? is error prone and things
like pipes can hide them. Using undefined variables is another thing
which should fail early before things go horribly wrong. And in build automation
I'd rather see output of -x since things can fail in mysterious ways.
And then there's quoting....
One useful guide is to use shellcheck as static analysis tool for shell scripts.
I guess internally bitbake uses at least set -e.
Comments?
-Mikko
next prev parent reply other threads:[~2015-08-12 10:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-05 9:01 [PATCH] create-pull-request: cd to relative directory Ed Bartosh
2015-08-06 3:33 ` Khem Raj
2015-08-06 8:38 ` Paul Eggleton
2015-08-06 9:07 ` Ed Bartosh
2015-08-06 15:05 ` Khem Raj
2015-08-06 15:16 ` Paul Eggleton
2015-08-06 16:16 ` Khem Raj
2015-08-11 14:24 ` [PATCH v2] " Ed Bartosh
2015-08-11 14:33 ` [PATCH v3] " Ed Bartosh
2015-08-12 9:33 ` [PATCH v4] create-pull-request: cleanup bashisms Ed Bartosh
2015-08-12 9:35 ` Khem Raj
2015-08-12 9:49 ` Mikko.Rapeli [this message]
2015-08-12 16:56 ` shell script guidelines in oe-core? (was Re: [PATCH v4] create-pull-request: cleanup bashisms) Khem Raj
2015-08-12 17:46 ` Christopher Larson
2015-08-12 17:51 ` Christopher Larson
2015-08-13 6:27 ` Mikko.Rapeli
2015-08-14 22:01 ` Christopher Larson
2015-08-16 1:38 ` Christopher Larson
2015-08-17 6:14 ` Mikko.Rapeli
2015-08-17 10:52 ` Otavio Salvador
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150812094953.GL6102@loska \
--to=mikko.rapeli@bmw.de \
--cc=ed.bartosh@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.