Re: fatal from submodule status --recursive when used with grep -q
- From
- phillip.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 yI'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