git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: fatal from submodule status --recursive when used with grep -q

From
Pphillip.wood123@gmail.com <phillip.wood123@gmail.com>
Date
Sep 20, 2024, 13:12 UTC
Message-ID
<c2ce33c1-b9d2-4798-b91e-4e0a55e97052@gmail.com>
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:
Show 6 quoted lines
> 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

Previous: Matt Liberty
Message 11 of 11 in “fatal from submodule status --recursive when used with grep -q”
  1. Matt LibertySep 16, 2024
  2. Phillip WoodSep 18, 2024
  3. Matt LibertySep 18, 2024
  4. Junio C HamanoSep 19, 2024
  5. Matt LibertySep 19, 2024
  6. phillip.wood123@gmail.comSep 19, 2024
  7. Matt LibertySep 19, 2024
  8. Junio C HamanoSep 19, 2024
  9. Eric SunshineSep 19, 2024
  10. Matt LibertySep 19, 2024
  11. phillip.wood123@gmail.comSep 20, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.