From: phillip.wood123@gmail.com Date: Fri, 20 Sep 2024 13:12:30 GMT Subject: Re: fatal from submodule status --recursive when used with grep -q Message-ID: In-Reply-To: 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 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