Re: [PATCH] submodule--helper: set alternateLocation for cloned submodules
- From
Jeff King <peff@peff.net>
- Date
- Dec 8, 2016, 18:53 UTC
- Message-ID
- <20161208185326.osknwhc654sqaq3t@sigill.intra.peff.net>
- In-Reply-To
- <d445a6c3-5375-22cf-4f03-1717559f1157@gmail.com>
On Thu, Dec 08, 2016 at 09:04:46PM +0300, vi0oss wrote:
> Why Git test use &&-chains instead of proper "set -e"?
Because "set -e" comes with all kinds of confusing corner cases. Using && chains is annoying, but rarely surprising.
One of my favorite examples is:
set -e
(
false
echo 1
) || {
echo outcome=$?
false
}
echo 2which prints both "1" and "2".
Inside the subshell, "set -e" has no effect, and you cannot re-enable it by setting "-e" (it's suppressed entirely because we are on the left-hand side of an || conditional).
So you could write a function like this:
foo() {
do_one
do_two
}that relies on catching the failure from do_one. And it works here:
set -e foo
but not here:
set -e
if foo then
do_something
fiAnd there's no way to make it work without adding back in the &&-chaining.
-Peff