git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: phillip.wood123@gmail.com
To: Matt Liberty <mliberty@precisioninno.com>,
	Eric Sunshine <sunshine@sunshineco.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	phillip.wood@dunelm.org.uk, git@vger.kernel.org
Subject: Re: fatal from submodule status --recursive when used with grep -q
Date: Fri, 20 Sep 2024 14:12:30 +0100	[thread overview]
Message-ID: <c2ce33c1-b9d2-4798-b91e-4e0a55e97052@gmail.com> (raw)
In-Reply-To: <CAKDm0rPNLtv48P4JOKNicMcrz=ZZwr9PwE207D_foj1r-pn5UQ@mail.gmail.com>

Hi Matt

[please reply in-line to avoid breaking the flow of the conversation]

On 19/09/2024 21:10, Matt Liberty wrote:
> On Thu, Sep 19, 2024 at 12:40 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
>>
>> Regarding the exit code, it's not even clear how that factors into
>> this discussion considering that, in the presented example,
>> git-submodule is upstream of a pipe, thus its exit code is lost
>> anyhow.
 >
 > The exit code matters if you do "set -euo pipefail".

When you use "grep -q" you know that if it is successful the upstream 
commands in the pipeline are likely to receive SIGPIPE. Therefore if you 
want to use "-o pipefail" to check that they do not fail unexpectedly 
you need to remap the exit code associated with SIGPIPE to zero. 
Something like [1]

	hide_sigpipe() {
		status=$?
		test $status -eq 141 && exit 0
		exit $status
	}
	(yes; hide_sigpipe) | grep -q y


I've posted a patch[2] that fixes the error message you were seeing.

Best Wishes

Phillip

[1] 
https://unix.stackexchange.com/questions/582844/how-to-suppress-sigpipe-in-bash
[2] 
https://lore.kernel.org/git/pull.1799.git.1726837642511.gitgitgadget@gmail.com

      reply	other threads:[~2024-09-20 13:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-16 15:08 fatal from submodule status --recursive when used with grep -q Matt Liberty
2024-09-18 10:05 ` Phillip Wood
2024-09-18 14:45   ` Matt Liberty
2024-09-19  1:16   ` Junio C Hamano
2024-09-19 13:23     ` Matt Liberty
     [not found]   ` <CAKDm0rMsXUpFSWRWkW0J0FUpEbot6wQqdzYTT5CLZ=3TGbV-OA@mail.gmail.com>
2024-09-19 14:22     ` phillip.wood123
2024-09-19 15:17       ` Matt Liberty
2024-09-19 19:09         ` Junio C Hamano
2024-09-19 19:40           ` Eric Sunshine
2024-09-19 20:10             ` Matt Liberty
2024-09-20 13:12               ` phillip.wood123 [this message]

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=c2ce33c1-b9d2-4798-b91e-4e0a55e97052@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=mliberty@precisioninno.com \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=sunshine@sunshineco.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.
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 NNTP newsgroup(s).