git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: vi0oss <vi0oss@gmail.com>
Cc: Stefan Beller <sbeller@google.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>,
	Stefan Beller <stefanbeller@gmail.com>
Subject: Re: [PATCH] submodule--helper: set alternateLocation for cloned submodules
Date: Thu, 8 Dec 2016 13:53:27 -0500	[thread overview]
Message-ID: <20161208185326.osknwhc654sqaq3t@sigill.intra.peff.net> (raw)
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 2

which 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
  fi

And there's no way to make it work without adding back in the
&&-chaining.

-Peff

  parent reply	other threads:[~2016-12-08 18:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-08  0:39 [PATCH] submodule--helper: set alternateLocation for cloned submodules vi0oss
2016-12-08  1:22 ` Stefan Beller
2016-12-08 17:46   ` Jeff King
2016-12-08 18:04     ` Stefan Beller
2016-12-08 18:04     ` vi0oss
2016-12-08 18:21       ` Stefan Beller
2016-12-08 18:53       ` Jeff King [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-12-12  2:45 vi0oss
2016-12-08  1:38 vi0oss
2016-12-10 13:41 ` vi0oss
2016-12-12  5:35   ` Stefan Beller
2016-12-12 18:00     ` Junio C Hamano
2016-12-07 18:42 vi0oss
2016-12-07 20:09 ` Stefan Beller
2016-12-07 20:18   ` Junio C Hamano
2016-12-07 20:26     ` Stefan Beller
2016-12-07 20:28       ` Junio C Hamano
2016-12-07 21:24   ` vi0oss
2016-12-07 22:09     ` Stefan Beller

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161208185326.osknwhc654sqaq3t@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=sbeller@google.com \
    --cc=stefanbeller@gmail.com \
    --cc=vi0oss@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).